GNU bug report logs - #60143
29.0.60; command `undo-redo` don't restore cursor position

Previous Next

Package: emacs;

Reported by: yinz Liu <liuyinz95 <at> gmail.com>

Date: Sat, 17 Dec 2022 03:35:04 UTC

Severity: wishlist

Found in version 29.0.60

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: yinz Liu <liuyinz95 <at> gmail.com>, Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 60143 <at> debbugs.gnu.org
Subject: bug#60143: 29.0.60; command `undo-redo` don't restore cursor position
Date: Sun, 18 Dec 2022 13:03:43 +0200
> From: yinz Liu <liuyinz95 <at> gmail.com>
> Date: Sat, 17 Dec 2022 09:42:28 +0800
> 
> aaaa ! bbbb @ cccc #
> 
> 1. when cursor at position "#", call `undo', cursor jump to "@"
> 
> 2. when cursor at position "@", call `undo-redo', text "cccc" restore,
>    but cursor still remain in "@", don't move to "#".
> 
> my workaround fow now:
> 
> in function primitive-undo :
> 
> change L3624 to : `(goto-char (+ pos (length string)))`

That code is there for almost 10 years, and before that the C
implementation did the same.  The way the code is written, viz.:

               (goto-char pos)
               (insert string)
               (goto-char pos))

it is clear that the second goto-char is on purpose, since if we
delete it, we get the effect that you want; no need to goto anywhere
else, because 'insert' leaves point after the inserted text.

So I very much hesitate to change this.  Stefan, any comments? do you
happen to know why we return point to before the insertion?




This bug report was last modified 1 year and 290 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.