sabato 17 novembre 2012

Emacs Buffer List: ibuffer

The buffer list (C-x C-b) is one of the features of Emacs that I use the most: I work with a lot of buffer and sometimes I get "lost" among them, so I need a quick place to see what I'm editing and quite frankly the buffers list does it well.
However the buffers list works opening a new buffer to allow the user to select the buffer to pop up again, and quite oddily it does not close the buffers list buffer (named "*Buffer List*") after the user has chosen the buffer to edit.
This means that users have to manually close the buffer list window, switching to the editing buffer. Moreover, when the buffer list opens it does not get the focus, so that the lifecycle of using the buffers list results in:
- C-x C-b
- C-x o to give the buffers list the focus
- n/p to move around the buffer entries
- [Enter] to select a buffer
- kill the buffer list (C-x 1 on the other window)

Since the above is quite annoying, I wrote a simple function to wrap the default buffer-list one so that at least it gets the focus automatically.

The function simply calls the original buffer-list and then advance to the next window, that in this case is always the buffer list itself.
However, this does not solve the problem of closing the buffers list window when done. Therefore, while searching the Web I found a more interesting function: ibuffer. Such function opens a more advanced buffers list that automatically get closed when a selection is done.
Therefore my .emacs file now has an entry to remap the C-x C-b key sequence to the ibuffer function:

(global-set-key (kbd "C-x C-b") 'ibuffer)

Nessun commento: