I have some sample code like this:

(defun some-function ()
  (goto-char (point-min))
  ; do some stuff

Now I'm expecting pop-mark to get me back to the original location. But that doesn't seem to be happening. Any idea on how to do this properly ?

  • I would recommend storing your location points in let-bound variables and then going back there again: (let* ((point-one (point)) point-two) (goto-char (point-min)) [do stuff . . .] (goto-char point-one)) You can create a place holder for the variable -- e.g., point-two and then when you get there, set it with (setq point-two (point))
    – lawlist
    Commented May 5, 2015 at 2:24

1 Answer 1


From pop-mark's documentation: ...This does not move point in the buffer

I think you want:

;; do some stuff
(goto-char (mark))

But if all you care about is returning to a previous location, and not actually using the mark ring, then you could either

1) save (point) in a variable and return to it

2) use save-excursion which does this for you

  • 8
    save-excursion really is the best way to do this. You don't have to worry about saving the initial position of point, just let save-excursion do the work for you.
    – zck
    Commented May 5, 2015 at 3:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.