[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/intervals.c
From: |
Miles Bader |
Subject: |
[Emacs-diffs] Changes to emacs/src/intervals.c |
Date: |
Thu, 14 Mar 2002 03:11:46 -0500 |
Index: emacs/src/intervals.c
diff -c emacs/src/intervals.c:1.112 emacs/src/intervals.c:1.113
*** emacs/src/intervals.c:1.112 Fri Dec 28 00:12:42 2001
--- emacs/src/intervals.c Thu Mar 14 03:11:46 2002
***************
*** 1,5 ****
/* Code for doing intervals.
! Copyright (C) 1993, 1994, 1995, 1997, 1998 Free Software Foundation, Inc.
This file is part of GNU Emacs.
--- 1,5 ----
/* Code for doing intervals.
! Copyright (C) 1993, 1994, 1995, 1997, 1998, 2002 Free Software Foundation,
Inc.
This file is part of GNU Emacs.
***************
*** 1883,1888 ****
--- 1883,1934 ----
set_point_both (buffer, charpos, buf_charpos_to_bytepos (buffer, charpos));
}
+ /* If there's an invisible character at position POS + TEST_OFFS in the
+ current buffer, and the invisible property has a `stickiness' such that
+ inserting a character at position POS would inherit the property it,
+ return POS + ADJ, otherwise return POS. If TEST_INTANG is non-zero,
+ then intangibility is required as well as invisibleness.
+
+ TEST_OFFS should be either 0 or -1, and ADJ should be either 1 or -1.
+
+ Note that `stickiness' is determined by overlay marker insertion types,
+ if the invisible property comes from an overlay. */
+
+ static int
+ adjust_for_invis_intang (pos, test_offs, adj, test_intang)
+ int pos, test_offs, adj, test_intang;
+ {
+ Lisp_Object invis_propval, invis_overlay;
+ Lisp_Object test_pos;
+
+ if ((adj < 0 && pos + adj < BEGV) || (adj > 0 && pos + adj > ZV))
+ /* POS + ADJ would be beyond the buffer bounds, so do no adjustment. */
+ return pos;
+
+ test_pos = make_number (pos + test_offs);
+
+ invis_propval
+ = get_char_property_and_overlay (test_pos, Qinvisible, Qnil,
+ &invis_overlay);
+
+ if ((!test_intang
+ || ! NILP (Fget_char_property (test_pos, Qintangible, Qnil)))
+ && TEXT_PROP_MEANS_INVISIBLE (invis_propval)
+ /* This next test is true if the invisible property has a stickiness
+ such that an insertion at POS would inherit it. */
+ && (NILP (invis_overlay)
+ /* Invisible property is from a text-property. */
+ ? (text_property_stickiness (Qinvisible, make_number (pos))
+ == (test_offs == 0 ? 1 : -1))
+ /* Invisible property is from an overlay. */
+ : (test_offs == 0
+ ? XMARKER (OVERLAY_START (invis_overlay))->insertion_type == 0
+ : XMARKER (OVERLAY_END (invis_overlay))->insertion_type == 1)))
+ pos += adj;
+
+ return pos;
+ }
+
/* Set point in BUFFER to CHARPOS, which corresponds to byte
position BYTEPOS. If the target position is
before an intangible character, move to an ok place. */
***************
*** 1975,2000 ****
or end of the buffer, so don't bother checking in that case. */
&& charpos != BEGV && charpos != ZV)
{
- Lisp_Object intangible_propval, invisible_propval;
Lisp_Object pos;
! int invis_p;
!
! XSETINT (pos, charpos);
if (backwards)
{
! /* If the preceding char is both invisible and intangible,
! start backing up from just before that one. */
!
! intangible_propval
! = Fget_char_property (make_number (charpos - 1),
! Qintangible, Qnil);
! invisible_propval
! = Fget_char_property (make_number (charpos - 1), Qinvisible, Qnil);
! invis_p = TEXT_PROP_MEANS_INVISIBLE (invisible_propval);
! if (! NILP (intangible_propval) && invis_p)
! XSETINT (pos, --charpos);
/* If following char is intangible,
skip back over all chars with matching intangible property. */
--- 2021,2039 ----
or end of the buffer, so don't bother checking in that case. */
&& charpos != BEGV && charpos != ZV)
{
Lisp_Object pos;
! Lisp_Object intangible_propval;
if (backwards)
{
! /* If the preceeding character is both intangible and invisible,
! and the invisible property is `rear-sticky', perturb it so
! that the search starts one character earlier -- this ensures
! that point can never move to the end of an invisible/
! intangible/rear-sticky region. */
! charpos = adjust_for_invis_intang (charpos, -1, -1, 1);
! XSETINT (pos, charpos);
/* If following char is intangible,
skip back over all chars with matching intangible property. */
***************
*** 2008,2017 ****
--- 2047,2072 ----
Qintangible, Qnil),
intangible_propval))
pos = Fprevious_char_property_change (pos, Qnil);
+
+ /* Set CHARPOS from POS, and if the final intangible character
+ that we skipped over is also invisible, and the invisible
+ property is `front-sticky', perturb it to be one character
+ earlier -- this ensures that point can never move to the
+ beginning of an invisible/intangible/front-sticky region. */
+ charpos = adjust_for_invis_intang (XINT (pos), 0, -1, 0);
}
}
else
{
+ /* If the following character is both intangible and invisible,
+ and the invisible property is `front-sticky', perturb it so
+ that the search starts one character later -- this ensures
+ that point can never move to the beginning of an
+ invisible/intangible/front-sticky region. */
+ charpos = adjust_for_invis_intang (charpos, 0, 1, 1);
+
+ XSETINT (pos, charpos);
+
/* If preceding char is intangible,
skip forward over all chars with matching intangible property. */
***************
*** 2025,2046 ****
intangible_propval))
pos = Fnext_char_property_change (pos, Qnil);
! /* Is the last one invisible as well as intangible? */
!
! invisible_propval
! = Fget_char_property (make_number (XINT (pos) - 1),
! Qinvisible, Qnil);
! invis_p = TEXT_PROP_MEANS_INVISIBLE (invisible_propval);
!
! /* If so, advance one character more:
! don't stop after an invisible, intangible character. */
!
! if (invis_p && XINT (pos) < BUF_ZV (buffer))
! XSETINT (pos, XINT (pos) + 1);
}
}
- charpos = XINT (pos);
bytepos = buf_charpos_to_bytepos (buffer, charpos);
}
--- 2080,2094 ----
intangible_propval))
pos = Fnext_char_property_change (pos, Qnil);
! /* Set CHARPOS from POS, and if the final intangible character
! that we skipped over is also invisible, and the invisible
! property is `rear-sticky', perturb it to be one character
! later -- this ensures that point can never move to the
! end of an invisible/intangible/rear-sticky region. */
! charpos = adjust_for_invis_intang (XINT (pos), -1, 1, 0);
}
}
bytepos = buf_charpos_to_bytepos (buffer, charpos);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] Changes to emacs/src/intervals.c,
Miles Bader <=