Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In Emacs how can I go back to the last buffer I was editing in ELisp?

share|improve this question
Can you give a little context about what you're trying to do? There are a bunch of different ways to do what you want but they depend on the bigger picture... – Joe Casadonte Dec 20 '10 at 18:51

If you changed the buffer in ELisp code, the proper way to go back to the previous buffer is to use save-excursion or save-current-buffer:

;; do stuff in buffer1
  (set-buffer "buffer2")
  ;; do stuff in buffer2
;; more stuff in buffer1
share|improve this answer

In emacs you would do "Ctrl-x b" to do that, so to find the Elisp function, do "Ctrl-h k" followed by "ctrl-x b" and you'll get:

[...] (switch-to-buffer BUFFER-OR-NAME &optional NORECORD)

Make BUFFER-OR-NAME current and display it in selected window. BUFFER-OR-NAME may be a buffer, a string (a buffer name), or nil. Return the buffer switched to. [...]

which should do what you want ;)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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