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

Carl Worth cworth at cworth.org
Tue May 24 15:01:04 PDT 2011


On Wed, 25 May 2011 00:43:20 +0400, Dmitry Kurochkin <dmitry.kurochkin at gmail.com> wrote:
> 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.

Ah. So that explains why your patch is actually making a difference.

But I've usually had "jumping cursor" problems when using an integer,
(and switching to a marker fixes it). For example, imagine the following
operation:

	User positions cursor on some word
	Our code saves point as an integer
	Some operation inserts new text before point
	Our code restores the cursor to the saved integer

This sequence restores point to the same integer position in the buffer,
but logically makes the cursor appear to "jump" to the user, (since the
cursor will no longer be on the word it was on before but will now be
earlier in the buffer).

The fix for the above is to switch from an integer to a marker.

So I'm curious to know the case you're hitting where you getbetter
behavior by switching from a marker to an integer. Can you describe it
in a bit more detail?

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20110524/4390ff20/attachment.pgp>


More information about the notmuch mailing list