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

Dmitry Kurochkin dmitry.kurochkin at gmail.com
Tue May 24 16:00:43 PDT 2011


On Tue, 24 May 2011 18:43:41 -0400, Austin Clements <amdragon at mit.edu> wrote:
> On Tue, May 24, 2011 at 6:16 PM, Dmitry Kurochkin
> <dmitry.kurochkin at gmail.com> wrote:
> > When a user clicks the button, the cursor is somewhere inside the old
> > label.  If we save the point as a marker, after step 3 it would end up
> > at the position where the old label was.  If the new label is inserted
> > before the old one, that means after the new label.  So the cursor jumps
> > from inside the button to the position after the button.  Since the new
> > button is placed at the same position where the old one was, restoring
> > the point to the same offset it was at the beginning works as we need.
> 
> Saving point this way is a bit dangerous, though.  For example, if
> you're near the end of the buffer and shorten the label, attempting to
> restore the point could result in an error (or, a more benign example:
> the cursor could wind up outside the label so pressing RET repeatedly
> won't toggle it).
> 
> Unfortunately, I don't know of a clean solution to this, but I think I
> would rather the cursor move, but stay within the label (probably
> moving to the beginning), than have problems like the above.

Good point.  I will send an amended patch that moved to min(old-pos,
new-button-end - 1).  This leaves the cursor in place when possible and
avoids problems with out-of-bounds position (assuming the label is not
empty).

Regards,
  Dmitry


More information about the notmuch mailing list