Re: [PATCH] Save and restore point explicitly in `notmuch-wash-toggle-invisible-action'.

Subject: Re: [PATCH] Save and restore point explicitly in `notmuch-wash-toggle-invisible-action'.

Date: Tue, 24 May 2011 13:20:56 -0700

To: Dmitry Kurochkin, notmuch@notmuchmail.org

Cc:

From: Carl Worth


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

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?

-Carl

-- 
carl.d.worth@intel.com
part-000.sig (application/pgp-signature)

Thread: