Note: IswitchB was part of GnuEmacs, but it has been removed starting with Emacs 24.4. The Emacs
‘C-h N’) says to use IcompleteMode instead, but for those wanting more familiar functionality, InteractivelyDoThings is a closer fit. Emacs Devs have removed IswitchB from the product, and it is not available on GNU ELPA, but you can still find it here: http://cvs.savannah.gnu.org/viewvc/*checkout*/emacs/emacs/lisp/iswitchb.el
‘C-x b’ calls
‘switch-to-buffer’. An alternative,
‘iswitchb-buffer’, is also available. As you type the buffer name, the list of options is reduced to the buffers matching what you type. And it is not limited to the beginning of the buffer name, either. That means you could type “tch” to switch to the “scratch” buffer.
For latest Emacs, use:
If you are using GNU Emacs older than 21, put this in your InitFile:
To prevent certain buffers from showing up in the completion list, set
(setq iswitchb-buffer-ignore '("^ " "*Buffer"))
This one is useful if you want to lose the *…* special buffers from the list. It’s helpful if you’re using the JDEE for editing Java apps, as you end up with buffers named org.whatever.package.Class which you might want to eliminate:
(setq iswitchb-buffer-ignore '("^\\*"))
To prevent switching to another frame, you can add the following to your configuration:
(setq iswitchb-default-method 'samewindow)
For more about iswitch-buffer, see UseIswitchBuffer.
The default key bindings to select a buffer might annoy some. Even more annoying is the fact that the left/right keys don’t work, and the up/down keys unhelpfully bring up old iswitchb lists which might even be out of date. With that in mind:
(defun iswitchb-local-keys () (mapc (lambda (K) (let* ((key (car K)) (fun (cdr K))) (define-key iswitchb-mode-map (edmacro-parse-keys key) fun))) '(("<right>" . iswitchb-next-match) ("<left>" . iswitchb-prev-match) ("<up>" . ignore ) ("<down>" . ignore ))))
(add-hook 'iswitchb-define-mode-map-hook 'iswitchb-local-keys)
in your .emacs will allow left/right arrow key navigation of the buffer list, and deactivate up/down in iswitchb. Note that you can by default use C-s and C-r to do this. – fledermaus
If the above fails with “define-key: Symbol’s function definition is void: edmacro-parse-keys” you need to load the package defining edmacro with
(require 'edmacro). – Caldrin
The library uniquify overrides Emacs’ default mechanism for making buffer names unique (using suffixes like
<3> etc.) with a more sensible behaviour which use parts of the file names to make the buffer names distinguishable.
Additionally one can configure uniquify to rework the buffer names whenever a buffer is killed. This feature does not play well with IswitchBuffers function
‘iswitchb-kill-buffer’, bound to
C-k. The following code instructs
‘iswitchb-kill-buffer’ to update the buffer list after killing a buffer, so that a possible buffer renaming by uniquify is taken in account.
(defadvice iswitchb-kill-buffer (after rescan-after-kill activate) "*Regenerate the list of matching buffer names after a kill. Necessary if using `uniquify' with `uniquify-after-kill-buffer-p' set to non-nil." (setq iswitchb-buflist iswitchb-matches) (iswitchb-rescan))
(defun iswitchb-rescan () "*Regenerate the list of matching buffer names." (interactive) (iswitchb-make-buflist iswitchb-default) (setq iswitchb-rescan t))
‘icicle-buffer’offers similar functionality, with either immediate buffer switching or switching-upon-confirmation. Like
‘iswitch-buffer’, you can match any part of a buffer name. You can also use a regexp to match the name. And Icicles provides completion on buffer names.