From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
To: Carl Worth <cworth@cworth.org>, notmuch@notmuchmail.org
Subject: Re: [PATCH] Save and restore point explicitly in `notmuch-wash-toggle-invisible-action'.
Date: Wed, 25 May 2011 00:43:20 +0400 [thread overview]
Message-ID: <8762ozrfrr.fsf@gmail.com> (raw)
In-Reply-To: <87oc2rlujb.fsf@yoom.home.cworth.org>
Hi Carl.
On Tue, 24 May 2011 13:20:56 -0700, Carl Worth <cworth@cworth.org> wrote:
> On Mon, 23 May 2011 19:29:46 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
> > Before the change, save-excursion was used to save the point.
> > But the restored position is affected by buffer modifications,
> > which results in jumping cursor. The patch saves and restores
> > point explicitly by using a variable instead of save-excursion.
>
> Dmitry,
>
> Thanks so much for the improvement to the button text! This will be a
> nice thing to add.
>
> But this patch confuses me. I can understand how a buffer-position
> variable can cause the cursor to jump. That's usually the kind of thing
> that can be fixed by switching from an integer position to a marker
> instead, (since markers are updated when the corresponding text is
> updated).
>
So we need to switch from marker to an integer position, right?
> But in this case, I don't see how:
>
> (let ((old-point (point)))
> ... code here ...
> (goto-char old-point))
>
> is distinct from:
>
> (save-excursion
> ... code here ...
> )
>
> except that save-excursion actually does the right thing in the case of
> abnormal exit (throw or error).
>
> Can you help me understand what I'm missing here?
>
Unfortunately, I am not an Emacs lisp expert. I just noticed that the
cursor jumps and did the first thing that came to mind. And it worked.
Now, looking at Emacs source code, save_excursion_save() uses
point_marker() to save the point. As you said above, markers are
updated when the corresponding text is updated. That explains why the
cursor jumps when using `save-excursion'.
On the other hand, `point' returns position as an integer. Which is
just what we need.
Regards,
Dmitry
> -Carl
>
> --
> carl.d.worth@intel.com
Non-text part: application/pgp-signature
next prev parent reply other threads:[~2011-05-24 20:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-22 18:57 [PATCH 1/3] Use different labels for wash buttons when text is visible or hidden Dmitry Kurochkin
2011-05-22 18:57 ` [PATCH 2/3] test: fix expected output for emacs tests after the wash button label changes Dmitry Kurochkin
2011-05-22 18:57 ` [PATCH 3/3] test: add test for hiding/showing signature in notmuch-show view Dmitry Kurochkin
2011-05-23 15:29 ` [PATCH] Save and restore point explicitly in `notmuch-wash-toggle-invisible-action' Dmitry Kurochkin
2011-05-24 20:20 ` Carl Worth
2011-05-24 20:43 ` Dmitry Kurochkin [this message]
2011-05-24 22:01 ` Carl Worth
2011-05-24 22:16 ` Dmitry Kurochkin
2011-05-24 22:22 ` Carl Worth
2011-05-24 22:43 ` Austin Clements
2011-05-24 22:57 ` Carl Worth
2011-05-24 23:00 ` Dmitry Kurochkin
2011-05-24 23:02 ` Dmitry Kurochkin
2011-05-24 23:20 ` Carl Worth
2011-05-24 23:27 ` Dmitry Kurochkin
2011-05-24 23:36 ` Carl Worth
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
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8762ozrfrr.fsf@gmail.com \
--to=dmitry.kurochkin@gmail.com \
--cc=cworth@cworth.org \
--cc=notmuch@notmuchmail.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 public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).