diff options
| author | Lars Hansen | 2006-04-23 08:14:52 +0000 |
|---|---|---|
| committer | Lars Hansen | 2006-04-23 08:14:52 +0000 |
| commit | 59062dce6704f1eca7888d2f46d6e056be3da5cc (patch) | |
| tree | 740e8742f39db91fe9cb52ab83792d3a5a0ef91e /src/editfns.c | |
| parent | 01017e7c80daa05b1c7eaa82f69bf80af253bb87 (diff) | |
| download | emacs-59062dce6704f1eca7888d2f46d6e056be3da5cc.tar.gz emacs-59062dce6704f1eca7888d2f46d6e056be3da5cc.zip | |
(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.c | 28 |
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) | |||
| 491 | } | 491 | } |
| 492 | 492 | ||
| 493 | /* Find the field surrounding POS in *BEG and *END. If POS is nil, | 493 | /* Find the field surrounding POS in *BEG and *END. If POS is nil, |
| 494 | the value of point is used instead. If BEG or END null, | 494 | the value of point is used instead. If BEG or END is null, |
| 495 | means don't store the beginning or end of the field. | 495 | means don't store the beginning or end of the field. |
| 496 | 496 | ||
| 497 | BEG_LIMIT and END_LIMIT serve to limit the ranged of the returned | 497 | BEG_LIMIT and END_LIMIT serve to limit the ranged of the returned |
| 498 | results; they do not effect boundary behavior. | 498 | results; they do not effect boundary behavior. |
| 499 | 499 | ||
| 500 | If MERGE_AT_BOUNDARY is nonzero, then if POS is at the very first | 500 | If MERGE_AT_BOUNDARY is nonzero, then if POS is at the very last |
| 501 | position of a field, then the beginning of the previous field is | 501 | position of a field, then the end of the next field is returned |
| 502 | returned instead of the beginning of POS's field (since the end of a | 502 | instead of the end of POS's field (since the end of a field is |
| 503 | field is actually also the beginning of the next input field, this | 503 | actually also the beginning of the next input field, this behavior |
| 504 | behavior is sometimes useful). Additionally in the MERGE_AT_BOUNDARY | 504 | is sometimes useful). Additionally in the MERGE_AT_BOUNDARY |
| 505 | true case, if two fields are separated by a field with the special | 505 | true case, if two fields are separated by a field with the special |
| 506 | value `boundary', and POS lies within it, then the two separated | 506 | value `boundary', and POS lies within it, then the two separated |
| 507 | fields are considered to be adjacent, and POS between them, when | 507 | fields are considered to be adjacent, and POS between them, when |
| 508 | finding the beginning and ending of the "merged" field. | 508 | finding the beginning and ending of the "merged" field. */ |
| 509 | |||
| 510 | Either BEG or END may be 0, in which case the corresponding value | ||
| 511 | is not stored. */ | ||
| 512 | 509 | ||
| 513 | static void | 510 | static void |
| 514 | find_field (pos, merge_at_boundary, beg_limit, beg, end_limit, end) | 511 | 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. */) | |||
| 674 | (pos, escape_from_edge, limit) | 671 | (pos, escape_from_edge, limit) |
| 675 | Lisp_Object pos, escape_from_edge, limit; | 672 | Lisp_Object pos, escape_from_edge, limit; |
| 676 | { | 673 | { |
| 677 | int beg; | 674 | int beg, end; |
| 678 | find_field (pos, escape_from_edge, limit, &beg, Qnil, 0); | 675 | find_field (pos, escape_from_edge, limit, &beg, Qnil, &end); |
| 679 | return make_number (beg); | 676 | /* When pos is at a field boundary and escape_from_edge (merge_at_boundary) |
| 677 | is nil, find_field returns the *previous* field. In this case we return | ||
| 678 | end instead of beg. */ | ||
| 679 | return make_number (NILP (escape_from_edge) | ||
| 680 | && XFASTINT (pos) == end | ||
| 681 | && end != ZV ? end : beg); | ||
| 680 | } | 682 | } |
| 681 | 683 | ||
| 682 | DEFUN ("field-end", Ffield_end, Sfield_end, 0, 3, 0, | 684 | DEFUN ("field-end", Ffield_end, Sfield_end, 0, 3, 0, |