all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: `vertical-motion', `goto-line' set point to invisible text
Date: Sun, 03 Jul 2011 11:31:23 +0400	[thread overview]
Message-ID: <87liwf4y7o.fsf@gmail.com> (raw)
In-Reply-To: <E1QdGaZ-0003T2-4z@fencepost.gnu.org>

Hi Eli.

On Sun, 03 Jul 2011 02:55:31 -0400, Eli Zaretskii <eliz@gnu.org> wrote:
> > From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
> > 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.
> 

Thanks for the hint.

> > 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?

Yes, I know invisible is not the same as 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.

I guess that explains why in notmuch (which has multiple lines hidden,
i.e. email body) I hit C-a, then M-: "(point)" I get X, then if I do M-:
"(point)" again, I get Y.  Is there a way to ask Emacs to sync point to
visible position, so that I do not have to do it by hand?

>  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?
> 
> Yes.
> 

Thanks for your answers.

> 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.

Indeed, I did not notice that when testing in notmuch (I guess because
there are many lines hidden).

`backward-char' steps 1 position as expected.  I.e. M-: (progn
(backward-char) (point)) works fine.  But after that M-: (point) returns
another position which corresponds to the beginning of the hidden line.
I guess this has to do command loop I know nothing about.  IMO Emacs
should not touch the point in this case, because it is already visible.
Sounds like a bug to me.

Regards,
  Dmitry



  reply	other threads:[~2011-07-03  7:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-03  2:59 `vertical-motion', `goto-line' set point to invisible text Dmitry Kurochkin
2011-07-03  6:55 ` Eli Zaretskii
2011-07-03  7:31   ` Dmitry Kurochkin [this message]
2011-07-03 13:33     ` Eli Zaretskii
2011-07-04  2:08       ` Dmitry Kurochkin
2011-07-03 14:50 ` Stefan Monnier
2011-07-03 15:14   ` Eli Zaretskii
2011-07-04 14:01     ` Stefan Monnier
2011-07-04 15:14       ` Eli Zaretskii
2011-07-04 18:10         ` Stefan Monnier
2011-07-04 20:06           ` Eli Zaretskii
2011-07-04 20:06           ` Eli Zaretskii
2011-07-05  2:22           ` Dmitry Kurochkin
2011-07-05  2:55             ` Eli Zaretskii
2011-07-05  3:52             ` Dmitry Kurochkin
2011-07-05  7:56               ` Eli Zaretskii
2011-07-09 13:13                 ` Dmitry Kurochkin

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=87liwf4y7o.fsf@gmail.com \
    --to=dmitry.kurochkin@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /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.