Ads by Google

Saturday, April 17, 2010

Remembering the last edited location in a file

From the emacs newsgroup, one way to get to back to the last editing location in the file is described here in this thread. Pretty useful, if you jump between a lot of files and need to scroll down to the end every time or some such repeatable action.

1 comment:

Unknown said...

That's not really the last edited location but the last position of the cursor. To be able to get back to the last edit point in a buffer is also very useful. I'm doing it like this:

(defun goto-last-edit-point ()
"Go to the last point where editing occurred."
(let ((undos buffer-undo-list))
(when (listp undos)
(while (and undos
(let ((pos (or (cdr-safe (car undos))
(car undos))))
(not (and (integerp pos)
(goto-char (abs pos))))))
(setq undos (cdr undos))))))

(global-set-key (kbd "C-c SPC") 'goto-last-edit-point)