[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: moving point over invisible and intangible text
From: |
Stefan Monnier |
Subject: |
Re: moving point over invisible and intangible text |
Date: |
22 Oct 2003 09:52:27 -0400 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
>> No, that part is already properly handled by the `intangible' handling
>> (which was already present in Emacs-20). What he was referring to is the
>> new code that treats intangible+invisible specially.
> Hmmm, now I'm confused...
I think it's the patch below,
Stefan
Index: intervals.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/intervals.c,v
retrieving revision 1.111
retrieving revision 1.113
diff -u -r1.111 -r1.113
*** intervals.c 9 Dec 2001 01:01:49 -0000 1.111
--- intervals.c 14 Mar 2002 08:11:46 -0000 1.113
***************
*** 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,2015 ****
or end of the buffer, so don't bother checking in that case. */
&& charpos != BEGV && charpos != ZV)
{
- Lisp_Object intangible_propval;
Lisp_Object pos;
!
! XSETINT (pos, charpos);
if (backwards)
{
! intangible_propval = Fget_char_property (make_number (charpos),
! Qintangible, Qnil);
/* If following char is intangible,
skip back over all chars with matching intangible property. */
if (! NILP (intangible_propval))
! while (XINT (pos) > BUF_BEGV (buffer)
! && EQ (Fget_char_property (make_number (XINT (pos) - 1),
! Qintangible, Qnil),
! intangible_propval))
! pos = Fprevious_char_property_change (pos, Qnil);
}
else
{
intangible_propval = Fget_char_property (make_number (charpos - 1),
Qintangible, Qnil);
- /* If following char is intangible,
- skip forward over all chars with matching intangible property. */
if (! NILP (intangible_propval))
! while (XINT (pos) < BUF_ZV (buffer)
! && EQ (Fget_char_property (pos, Qintangible, Qnil),
! intangible_propval))
! pos = Fnext_char_property_change (pos, Qnil);
!
}
- charpos = XINT (pos);
bytepos = buf_charpos_to_bytepos (buffer, charpos);
}
--- 2021,2094 ----
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. */
+
+ intangible_propval = Fget_char_property (pos, Qintangible, Qnil);
+
if (! NILP (intangible_propval))
! {
! while (XINT (pos) > BUF_BEGV (buffer)
! && EQ (Fget_char_property (make_number (XINT (pos) - 1),
! 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. */
+
intangible_propval = Fget_char_property (make_number (charpos - 1),
Qintangible, Qnil);
if (! NILP (intangible_propval))
! {
! while (XINT (pos) < BUF_ZV (buffer)
! && EQ (Fget_char_property (pos, Qintangible, Qnil),
! 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);
}
- Re: moving point over invisible and intangible text, (continued)
- Re: moving point over invisible and intangible text, Luc Teirlinck, 2003/10/18
- Re: moving point over invisible and intangible text, Richard Stallman, 2003/10/19
- Re: moving point over invisible and intangible text, Luc Teirlinck, 2003/10/19
- Re: moving point over invisible and intangible text, Richard Stallman, 2003/10/20
- Re: moving point over invisible and intangible text, Stefan Monnier, 2003/10/20
- Re: moving point over invisible and intangible text, Richard Stallman, 2003/10/22
- Re: moving point over invisible and intangible text, Stefan Monnier, 2003/10/22
- Re: moving point over invisible and intangible text, Miles Bader, 2003/10/22
- Re: moving point over invisible and intangible text, Stefan Monnier, 2003/10/22
- Re: moving point over invisible and intangible text, Miles Bader, 2003/10/22
- Re: moving point over invisible and intangible text,
Stefan Monnier <=
- Re: moving point over invisible and intangible text, Stefan Monnier, 2003/10/17
- Re: moving point over invisible and intangible text, Luc Teirlinck, 2003/10/17
- Re: moving point over invisible and intangible text, Luc Teirlinck, 2003/10/19
- Re: moving point over invisible and intangible text, Stefan Monnier, 2003/10/19
- Re: moving point over invisible and intangible text, Richard Stallman, 2003/10/16
- Re: moving point over invisible and intangible text, Richard Stallman, 2003/10/17
Re: moving point over invisible and intangible text, Klaus Zeitler, 2003/10/15