Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
1  
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
add comment

2 Answers 2

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
(save-excusion
  (set-buffer "buffer2")
  ;; do stuff in buffer2
  )
;; more stuff in buffer1
share|improve this answer
add comment

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
add comment

Your Answer

 
discard

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.