[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: `vertical-motion', `goto-line' set point to invisible text

From: Eli Zaretskii
Subject: Re: `vertical-motion', `goto-line' set point to invisible text
Date: Sun, 03 Jul 2011 02:55:31 -0400

> From: Dmitry Kurochkin <address@hidden>
> Date: Sun, 03 Jul 2011 06:59:49 +0400
> While working on notmuch [1] emacs client, I stumbled upon an unexpected
> behavior: `beginning-of-visual-line' places point to invisible text in
> the beginning to the line.  I.e. you have:
>   line1
>   line2    <--- this line is not visible
>   line3    <--- point is on this line
> in this case, `beginning-of-visual-line' will set the position to start
> of line2 (which is invisible), not line3.  It differs from what
> `move-beginning-of-line' and even does not match
> `line-beginning-position'.  `beginning-of-visual-line' uses
> `vertical-motion' to do the job.  `goto-line' has a similar behavior.  I
> believe there are more functions like this.

See the node "Invisible Text" in the ELisp manual.  Some functions are
explicitly programmed to special behavior in the vicinity of invisible
text, others aren't.

> This does not look right to me.  I expect these functions never set
> point inside invisible text and there should be some general way to
> protect from this.

Are you sure you don't mix invisible with intangible?  Invisible means
just that: not shown on the screen.  It doesn't mean point cannot
enter the invisible portion.  Emacs does try to move point out of
invisible range of text, but it does so in its command loop, _after_
the cursor motion functions and the display engine did their job.  So
your test program just shows that cursor motion has no problem getting
into the invisible region, which I think is not a bug.

> But perhaps I am wrong and we have to manually skip
> all invisible text forward after any point move?


There is something strange in how we behave in this example, though.
To see it, modify your test program to make each line's 1st character
different from other lines.  Then, after the program ends, C-a on the
3rd line and type "C-x =": Emacs says the character at point is the
first character of the invisible line 2, which seems wrong, as the
display shows line 3.  In fact, you cannot place point on the 1st
character of line 3: C-b from the 2nd character of line 3 gets you to
the 1st character of line 2!  I think this happens because the range
of invisible characters includes the newline of line 2.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]