summaryrefslogtreecommitdiff
path: root/src/editfns.c
diff options
context:
space:
mode:
authorLars Hansen <larsh@soem.dk>2006-04-23 08:14:27 +0000
committerLars Hansen <larsh@soem.dk>2006-04-23 08:14:27 +0000
commitaea2f45399b59b46a206bcaaefa5f9b3e0e451fd (patch)
treeef88cf1b4be14b1a6b097d58c5752d4ef8338137 /src/editfns.c
parent97bc35359c37ba5963daab543118baaa603ffc45 (diff)
downloademacs-aea2f45399b59b46a206bcaaefa5f9b3e0e451fd.tar.gz
(find_field): Fix comment.
(Ffield_beginning): Fix bug when POS is at field beginning.
Diffstat (limited to 'src/editfns.c')
-rw-r--r--src/editfns.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/editfns.c b/src/editfns.c
index 450a7684584..7466639012d 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -491,24 +491,21 @@ get_pos_property (position, prop, object)
}
/* Find the field surrounding POS in *BEG and *END. If POS is nil,
- the value of point is used instead. If BEG or END null,
+ the value of point is used instead. If BEG or END is null,
means don't store the beginning or end of the field.
BEG_LIMIT and END_LIMIT serve to limit the ranged of the returned
results; they do not effect boundary behavior.
- If MERGE_AT_BOUNDARY is nonzero, then if POS is at the very first
- position of a field, then the beginning of the previous field is
- returned instead of the beginning of POS's field (since the end of a
- field is actually also the beginning of the next input field, this
- behavior is sometimes useful). Additionally in the MERGE_AT_BOUNDARY
+ If MERGE_AT_BOUNDARY is nonzero, then if POS is at the very last
+ position of a field, then the end of the next field is returned
+ instead of the end of POS's field (since the end of a field is
+ actually also the beginning of the next input field, this behavior
+ is sometimes useful). Additionally in the MERGE_AT_BOUNDARY
true case, if two fields are separated by a field with the special
value `boundary', and POS lies within it, then the two separated
fields are considered to be adjacent, and POS between them, when
- finding the beginning and ending of the "merged" field.
-
- Either BEG or END may be 0, in which case the corresponding value
- is not stored. */
+ finding the beginning and ending of the "merged" field. */
static void
find_field (pos, merge_at_boundary, beg_limit, beg, end_limit, end)
@@ -674,9 +671,14 @@ is before LIMIT, then LIMIT will be returned instead. */)
(pos, escape_from_edge, limit)
Lisp_Object pos, escape_from_edge, limit;
{
- int beg;
- find_field (pos, escape_from_edge, limit, &beg, Qnil, 0);
- return make_number (beg);
+ int beg, end;
+ find_field (pos, escape_from_edge, limit, &beg, Qnil, &end);
+ /* When pos is at a field boundary and escape_from_edge (merge_at_boundary)
+ is nil, find_field returns the *previous* field. In this case we return
+ end instead of beg. */
+ return make_number (NILP (escape_from_edge)
+ && XFASTINT (pos) == end
+ && end != ZV ? end : beg);
}
DEFUN ("field-end", Ffield_end, Sfield_end, 0, 3, 0,