Ages ago I did the minimally required amount of work to get Chris Done’s goto-last-point to MELPA. Recently the maintenance of that package has been taken over by someone else as part of me moving away from GitHub and caring only about projects I want to actively maintain.
The thing with goto-last-point
is that it’s too much code for me. I simply
want to jump back to the last change in the buffer when I need. A savvy Emacs
user knows that commands such as isearch-forward
(C-s
) or
beginning-of-buffer
(M-<
) push mark at the previous position,
making it easy to go back to that position with a quick C-u C-SPC
.
However, suppose for a moment that for some inexplicable reason you reached over to the scroll wheel to move around your buffer. C-u C-SPC cannot help you now.
(defun mu-back-to-last-edit ()
"Jump back to the last change in the current buffer."
(interactive)
(ignore-errors
(let ((inhibit-message t))
(undo-only)
(undo-redo))))
Bind mu-back-to-last-edit
to a key binding of your choice and no matter the
weird dances your point is put through, you can safely reach for the last edit
without thinking too much about it.
Note that I am using ignore-errors
and inhibit-message
just because both
undo-only
and undo-redo
display useful messages that, in this specific case
only, I don’t need. You could avoid them if you don’t mind some noise in the
echo area.