Mercurial > emacs
comparison src/editfns.c @ 70188:6d253e1d0183
(find_field): Fix comment.
(Ffield_beginning): Fix bug when POS is at field beginning.
author | Lars Hansen <larsh@soem.dk> |
---|---|
date | Sun, 23 Apr 2006 08:14:27 +0000 |
parents | 1e68e7f3b824 |
children | e9ea7c53ddc7 |
comparison
equal
deleted
inserted
replaced
70187:9c4afe63f0af | 70188:6d253e1d0183 |
---|---|
489 } | 489 } |
490 } | 490 } |
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) |
515 Lisp_Object pos; | 512 Lisp_Object pos; |
516 Lisp_Object merge_at_boundary; | 513 Lisp_Object merge_at_boundary; |
672 If LIMIT is non-nil, it is a buffer position; if the beginning of the field | 669 If LIMIT is non-nil, it is a buffer position; if the beginning of the field |
673 is before LIMIT, then LIMIT will be returned instead. */) | 670 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, |
683 doc: /* Return the end of the field surrounding POS. | 685 doc: /* Return the end of the field surrounding POS. |
684 A field is a region of text with the same `field' property. | 686 A field is a region of text with the same `field' property. |