Skip to navigation

Better buffer switching in Emacs

I’ve switched from XEmacs to Emacs, about a month back. I like it much better. On Xubuntu, many more things work “out of the box” (for example the Noweb mode for Sweave). X clipboard contents are immediately available for yanking!

One thing that’s always annoyed me in both XEmacs and Emacs was the buffer switching using C-x b. In theory, this has a nice history you can cycle through using the up arrow, but this history never contained all of my open buffers. About fifty percent of the time, for reasons only known to the Lisp gurus, it did not offer the one buffer I wanted to switch to, even if I only had three different buffers open. OTOH, it did always contain all kinds of buffers I never in my life want to even see, such as *scratch*, *Messages*, *ESS*. Yikes.

This is what does away with all of this (in ~/.emacs):

; Better buffer switching
(iswitchb-mode 1)
; Ignore all kinds of special Emacs buffers that start with a *, 
; but don't ignore the R process buffer (*R*)
(add-to-list 'iswitchb-buffer-ignore "*[^R]")

Not only does this have a sensible history to cycle through, C-x b shows the names of all open buffers in the minibuffer, and you can “find as you type”, even for parts of the buffer name that are not at the beginning. So you can immediately type the letters that are unique to that buffer name, handy when you’re working on a project where the .tex and several .R files all start with the same project prefix.

Comments are closed.