Mercurial > emacs
comparison src/editfns.c @ 68394:0b6d0aad4517
(Fconstrain_to_field): Fix behaviour on field boundaries.
(find_field): Set before_field to after_field when pos is at BEGV.
author | Károly Lőrentey <lorentey@elte.hu> |
---|---|
date | Thu, 26 Jan 2006 06:43:33 +0000 |
parents | a0208539b9a3 |
children | ee9f9dd4337d 7432ca837c8d |
comparison
equal
deleted
inserted
replaced
68393:b5ff41ef0331 | 68394:0b6d0aad4517 |
---|---|
524 = get_char_property_and_overlay (pos, Qfield, Qnil, NULL); | 524 = get_char_property_and_overlay (pos, Qfield, Qnil, NULL); |
525 before_field | 525 before_field |
526 = (XFASTINT (pos) > BEGV | 526 = (XFASTINT (pos) > BEGV |
527 ? get_char_property_and_overlay (make_number (XINT (pos) - 1), | 527 ? get_char_property_and_overlay (make_number (XINT (pos) - 1), |
528 Qfield, Qnil, NULL) | 528 Qfield, Qnil, NULL) |
529 : Qnil); | 529 /* Using nil here would be a more obvious choice, but it would |
530 fail when the buffer starts with a non-sticky field. */ | |
531 : after_field); | |
530 | 532 |
531 /* See if we need to handle the case where MERGE_AT_BOUNDARY is nil | 533 /* See if we need to handle the case where MERGE_AT_BOUNDARY is nil |
532 and POS is at beginning of a field, which can also be interpreted | 534 and POS is at beginning of a field, which can also be interpreted |
533 as the end of the previous field. Note that the case where if | 535 as the end of the previous field. Note that the case where if |
534 MERGE_AT_BOUNDARY is non-nil (see function comment) is actually the | 536 MERGE_AT_BOUNDARY is non-nil (see function comment) is actually the |
715 Lisp_Object new_pos, old_pos; | 717 Lisp_Object new_pos, old_pos; |
716 Lisp_Object escape_from_edge, only_in_line, inhibit_capture_property; | 718 Lisp_Object escape_from_edge, only_in_line, inhibit_capture_property; |
717 { | 719 { |
718 /* If non-zero, then the original point, before re-positioning. */ | 720 /* If non-zero, then the original point, before re-positioning. */ |
719 int orig_point = 0; | 721 int orig_point = 0; |
720 | 722 int fwd, prev_old, prev_new; |
723 | |
721 if (NILP (new_pos)) | 724 if (NILP (new_pos)) |
722 /* Use the current point, and afterwards, set it. */ | 725 /* Use the current point, and afterwards, set it. */ |
723 { | 726 { |
724 orig_point = PT; | 727 orig_point = PT; |
725 XSETFASTINT (new_pos, PT); | 728 XSETFASTINT (new_pos, PT); |
726 } | 729 } |
727 | 730 |
731 CHECK_NUMBER_COERCE_MARKER (new_pos); | |
732 CHECK_NUMBER_COERCE_MARKER (old_pos); | |
733 | |
734 fwd = (XFASTINT (new_pos) > XFASTINT (old_pos)); | |
735 | |
736 prev_old = make_number (XFASTINT (old_pos) - 1); | |
737 prev_new = make_number (XFASTINT (new_pos) - 1); | |
738 | |
728 if (NILP (Vinhibit_field_text_motion) | 739 if (NILP (Vinhibit_field_text_motion) |
729 && !EQ (new_pos, old_pos) | 740 && !EQ (new_pos, old_pos) |
730 && (!NILP (get_pos_property (new_pos, Qfield, Qnil)) | 741 && (!NILP (Fget_text_property (new_pos, Qfield, Qnil)) |
731 || !NILP (get_pos_property (old_pos, Qfield, Qnil))) | 742 || !NILP (Fget_text_property (old_pos, Qfield, Qnil)) |
743 /* To recognize field boundaries, we must also look at the | |
744 previous positions; we could use `get_pos_property' | |
745 instead, but in itself that would fail inside non-sticky | |
746 fields (like comint prompts). */ | |
747 || (XFASTINT (new_pos) > BEGV | |
748 && !NILP (Fget_text_property (prev_new, Qfield, Qnil))) | |
749 || (XFASTINT (old_pos) > BEGV | |
750 && !NILP (Fget_text_property (prev_old, Qfield, Qnil)))) | |
732 && (NILP (inhibit_capture_property) | 751 && (NILP (inhibit_capture_property) |
733 || NILP (get_pos_property (old_pos, inhibit_capture_property, Qnil)))) | 752 /* Field boundaries are again a problem; but now we must |
753 decide the case exactly, so we need to call | |
754 `get_pos_property' as well. */ | |
755 || (NILP (get_pos_property (old_pos, inhibit_capture_property, Qnil)) | |
756 && (XFASTINT (old_pos) <= BEGV | |
757 || NILP (Fget_text_property (old_pos, inhibit_capture_property, Qnil)) | |
758 || NILP (Fget_text_property (prev_old, inhibit_capture_property, Qnil)))))) | |
734 /* It is possible that NEW_POS is not within the same field as | 759 /* It is possible that NEW_POS is not within the same field as |
735 OLD_POS; try to move NEW_POS so that it is. */ | 760 OLD_POS; try to move NEW_POS so that it is. */ |
736 { | 761 { |
737 int fwd, shortage; | 762 int shortage; |
738 Lisp_Object field_bound; | 763 Lisp_Object field_bound; |
739 | |
740 CHECK_NUMBER_COERCE_MARKER (new_pos); | |
741 CHECK_NUMBER_COERCE_MARKER (old_pos); | |
742 | |
743 fwd = (XFASTINT (new_pos) > XFASTINT (old_pos)); | |
744 | 764 |
745 if (fwd) | 765 if (fwd) |
746 field_bound = Ffield_end (old_pos, escape_from_edge, new_pos); | 766 field_bound = Ffield_end (old_pos, escape_from_edge, new_pos); |
747 else | 767 else |
748 field_bound = Ffield_beginning (old_pos, escape_from_edge, new_pos); | 768 field_bound = Ffield_beginning (old_pos, escape_from_edge, new_pos); |