aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKároly Lőrentey2006-01-26 06:43:33 +0000
committerKároly Lőrentey2006-01-26 06:43:33 +0000
commite477bb0420e5bbb734ddce2d09c6d91f720a0b33 (patch)
tree7f450ece5120ccdc3e23f58fbff89893081f6976 /src
parent13c42cc53a44b65f96e06d600b5c5d59f6757679 (diff)
downloademacs-e477bb0420e5bbb734ddce2d09c6d91f720a0b33.tar.gz
emacs-e477bb0420e5bbb734ddce2d09c6d91f720a0b33.zip
(Fconstrain_to_field): Fix behaviour on field boundaries.
(find_field): Set before_field to after_field when pos is at BEGV.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog4
-rw-r--r--src/editfns.c42
2 files changed, 33 insertions, 13 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 9829d7162da..b7e3640934a 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,7 +1,7 @@
12006-01-26 L$,1 q(Brentey K,Aa(Broly <lorentey@elte.hu> 12006-01-26 L$,1 q(Brentey K,Aa(Broly <lorentey@elte.hu>
2 2
3 * editfns.c (Fconstrain_to_field): Use get_pos_property, not 3 * editfns.c (Fconstrain_to_field): Fix behaviour on field boundaries.
4 Fget_char_property. Fix bogus comment. 4 (find_field): Set before_field to after_field when pos is at BEGV.
5 (Fline_beginning_position, Fline_end_position): Clarify 5 (Fline_beginning_position, Fline_end_position): Clarify
6 confusing doc string. 6 confusing doc string.
7 7
diff --git a/src/editfns.c b/src/editfns.c
index 1ee7c968884..9be9232a9c7 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -526,7 +526,9 @@ find_field (pos, merge_at_boundary, beg_limit, beg, end_limit, end)
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
@@ -717,7 +719,8 @@ Field boundaries are not noticed if `inhibit-field-text-motion' is non-nil. */)
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 {
@@ -725,23 +728,40 @@ Field boundaries are not noticed if `inhibit-field-text-motion' is non-nil. */)
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 764
740 CHECK_NUMBER_COERCE_MARKER (new_pos);
741 CHECK_NUMBER_COERCE_MARKER (old_pos);
742
743 fwd = (XFASTINT (new_pos) > XFASTINT (old_pos));
744
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