From: "Stefan Monnier" <monnier+gnu/emacs@RUM.cs.yale.edu>
Subject: Re: Should invisible imply intangible?
Date: Tue, 05 Mar 2002 18:34:38 -0500 [thread overview]
Message-ID: <200203052334.g25NYcY04427@rum.cs.yale.edu> (raw)
In-Reply-To: 200203052304.g25N4pI03908@rum.cs.yale.edu
> > I wrote
> >
> > The change in adjust_point_for_property seems ok, and it might solve
> > this problem.
> >
> > However, subsequently I realized it should be somewhat different. The
> > buffer position just after the invisible text should be treated as
> > part of the range where point cannot be. (This is how invisible,
> > intangible text is handled now.)
>
> But that would make it very awkward for the user to insert text
> immediately after the invisible area.
>
> If we still want to provide the illusion that the text really isn't
> there at all, then we should treat either the buffer position
> immediately before or immediately after as part of the intangible text,
> depending on the direction of the motion (so that both positions
> can still be reached "easily").
And here is a patch that does just that.
Note that there are two (related) problems left:
- when the text is replaced by an ellipsis, the cursor is always drawn
after the ellipsis even if point is immediately *before* the invisible text.
- I feel like this new "pretend the text isn't there at all" behavior
works well for completely invisible text, but not for text with an
elipsis where it makes sense for C-f or C-b to only skip over
the hidden text rather than "the hidden text + 1".
Of course, the second point would be even more relevant if the first point
was addressed.
Stefan
Index: keyboard.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/keyboard.c,v
retrieving revision 1.660
diff -u -u -b -r1.660 keyboard.c
*** keyboard.c 4 Mar 2002 23:40:59 -0000 1.660
--- keyboard.c 5 Mar 2002 23:28:44 -0000
***************
*** 1741,1788 ****
/* Adjust point to a boundary of a region that has such a property
that should be treated intangible. For the moment, we check
! `composition' and `display' property. LAST_PT is the last position
! of point. */
static void
adjust_point_for_property (last_pt)
int last_pt;
{
int start, end;
! Lisp_Object val;
! int check_composition = 1, check_display = 1;
! while (check_composition || check_display)
{
! if (check_composition
! && PT > BEGV && PT < ZV
! && get_property_and_range (PT, Qcomposition, &val, &start, &end, Qnil)
! && COMPOSITION_VALID_P (start, end, val)
! && start < PT && end > PT
&& (last_pt <= start || last_pt >= end))
{
! if (PT < last_pt)
! SET_PT (start);
! else
! SET_PT (end);
! check_display = 1;
}
- check_composition = 0;
- if (check_display
- && PT > BEGV && PT < ZV
- && get_property_and_range (PT, Qdisplay, &val, &start, &end, Qnil)
- && display_prop_intangible_p (val)
- && start < PT && end > PT
- && (last_pt <= start || last_pt >= end))
- {
- if (PT < last_pt)
- SET_PT (start);
- else
- SET_PT (end);
- check_composition = 1;
- }
- check_display = 0;
}
}
/* Subroutine for safe_run_hooks: run the hook HOOK. */
--- 1741,1814 ----
/* Adjust point to a boundary of a region that has such a property
that should be treated intangible. For the moment, we check
! `composition', `display' and `invisible' properties.
! LAST_PT is the last position of point. */
!
! static int
! adjust_composition_valid_p (start, end, val)
! int start, end;
! Lisp_Object val;
! {
! return COMPOSITION_VALID_P (start, end, val);
! }
!
! static int
! adjust_text_prop_means_invisible (start, end, val)
! int start, end;
! Lisp_Object val;
! {
! return TEXT_PROP_MEANS_INVISIBLE (val);
! }
!
! static int
! adjust_display_prop_intangible_p (start, end, val)
! int start, end;
! Lisp_Object val;
! {
! return display_prop_intangible_p (val);
! }
static void
adjust_point_for_property (last_pt)
int last_pt;
{
int start, end;
! Lisp_Object val, overlay;
! struct {
! Lisp_Object prop; int (*pred) (int, int, Lisp_Object); int overlays;
! } proptable[] =
! { { Qcomposition, adjust_composition_valid_p, 0 },
! { Qinvisible, adjust_text_prop_means_invisible, 1 },
! { Qdisplay, adjust_display_prop_intangible_p, 1 } };
! int i = 0, lastdone = 0;
! do
{
! int textprop = 1;
! while (PT > BEGV && PT < ZV
! && ((proptable[i].overlays
! && (val = get_char_property_and_overlay (make_number (PT),
! proptable[i].prop,
! Qnil, &overlay),
! start = NILP (overlay)
! ? 0 : XINT (Foverlay_start (overlay)),
! end = NILP (overlay) ? 0 : XINT (Foverlay_end (overlay)),
! !NILP (val) && !NILP (overlay))
! && (textprop = 1))
! || (textprop
! && (textprop = 0,
! get_property_and_range (PT, proptable[i].prop,
! &val, &start, &end, Qnil))))
! && proptable[i].pred (start, end, val)
! && (PT < last_pt
! ? (start <= PT && end > PT) : (start < PT && end >= PT))
&& (last_pt <= start || last_pt >= end))
{
! SET_PT (PT < last_pt ? max (start - 1, BEGV) : min (end + 1, ZV));
! lastdone = i;
}
}
+ while (lastdone != (i = (i + 1) % 3));
}
/* Subroutine for safe_run_hooks: run the hook HOOK. */
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel
next prev parent reply other threads:[~2002-03-05 23:34 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-23 20:19 Should invisible imply intangible? Richard Stallman
2002-02-23 21:24 ` Paul Michael Reilly
2002-02-25 0:09 ` Richard Stallman
2002-02-25 5:10 ` Stefan Monnier
2002-02-26 20:13 ` Richard Stallman
2002-03-01 1:30 ` Stefan Monnier
2002-03-03 14:40 ` Richard Stallman
2002-03-03 17:11 ` Stefan Monnier
2002-03-04 23:41 ` Richard Stallman
2002-03-04 23:46 ` Stefan Monnier
2002-03-05 1:40 ` Stefan Monnier
2002-03-07 2:30 ` Richard Stallman
2002-03-04 23:41 ` Richard Stallman
2002-03-05 21:58 ` Richard Stallman
2002-03-05 23:04 ` Stefan Monnier
2002-03-05 23:34 ` Stefan Monnier [this message]
2002-03-09 20:03 ` Richard Stallman
2002-03-09 22:37 ` Stefan Monnier
2002-03-10 21:32 ` Richard Stallman
[not found] ` <200203102202.g2AM26q06798@rum.cs.yale.edu>
2002-03-11 19:06 ` Richard Stallman
2002-03-12 17:56 ` Stefan Monnier
2002-03-13 10:58 ` Richard Stallman
2002-03-13 11:19 ` David Kastrup
2002-03-15 3:41 ` Richard Stallman
2002-03-15 11:47 ` David Kastrup
2002-03-16 6:39 ` Richard Stallman
2002-03-16 11:58 ` David Kastrup
2002-03-18 9:06 ` Richard Stallman
2002-03-18 23:36 ` David Kastrup
2002-03-19 7:24 ` Eli Zaretskii
2002-03-19 11:12 ` David Kastrup
2002-03-16 0:22 ` Stefan Monnier
2002-03-16 0:56 ` Miles Bader
2002-03-16 0:59 ` Stefan Monnier
2002-03-16 1:25 ` David Kastrup
2002-03-17 10:06 ` Richard Stallman
2002-03-16 1:18 ` David Kastrup
2002-03-16 1:28 ` Stefan Monnier
2002-03-16 2:16 ` David Kastrup
2002-03-16 3:29 ` Miles Bader
2002-03-16 4:05 ` David Kastrup
2002-03-23 23:37 ` David Kastrup
2002-03-13 13:06 ` Stefan Monnier
2002-03-13 14:15 ` David Kastrup
2002-03-13 16:53 ` Stefan Monnier
2002-03-14 12:42 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200203052334.g25NYcY04427@rum.cs.yale.edu \
--to=monnier+gnu/emacs@rum.cs.yale.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.