[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5. Convenient Buffer Switching

With this package installed, as you type in a substring, the list of buffers currently matching the substring are displayed as you type. The list is ordered so that the most recent buffers visited come at the start of the list. The buffer at the start of the list will be the one visited when you press return. By typing more of the substring, the list is narrowed down so that gradually the buffer you want will be at the top of the list. Alternatively, you can use C-s and C-r to rotate buffer names in the list until the one you want is at the top of the list. Completion is also available so that you can see what is common to all of the matching buffers as you type.

For example, let's say we have two buffers called "123456" and "123", with "123456" the most recent. When I use `iswitchb', I first of all get presented with the list of all the buffers

`iswitch {123456,123}'

If I then press 2:

`iswitch 2[3]{123456,123}'

The list in {} are the matching buffers, most recent first (buffers visible in the current frame are put at the end of the list by default). At any time I can select the item at the head of the list by pressing RET. I can also bring the put the first element at the end of the list by pressing C-s, or put the last element at the head of the list by pressing C-r. The item in [] indicates what can be added to my input by pressing TAB. In this case, I will get `3' added to my input. So, press TAB:

`iswitch 23{123456,123}'

At this point, I still have two matching buffers. If I want the first buffer in the list, I simply press RET. If I wanted the second in the list, I could press C-s to move it to the top of the list and then RET to select it.

However, If I type 4, I only have one match left:

`iswitch 234[123456] [Matched]'

Since there is only one matching buffer left, it is given in `[]' and we see the text `[Matched]' afterwards. I can now press TAB or RET to go to that buffer.

If however, I now type a:

`iswitch 234a [No match]'

There are no matching buffers. If I press RET or TAB, I can be prompted to create a new buffer called "234a".

Of course, where this function comes in really useful is when you can specify the buffer using only a few keystrokes. In the above example, the quickest way to get to the "123456" buffer would be just to type 4 and then RET (assuming there isn't any newer buffer with "4" in its name).

To see a full list of all matching buffers in a separate buffer, hit ? or press TAB when there are no further completions to the substring. Repeated TAB presses will scroll you through this separate buffer.

The buffer at the head of the list can be killed by pressing C-k. If the buffer needs saving, you will be queried before the buffer is killed.

If you find that the file you are after is not in a buffer, you can press C-x C-f to immediately drop into find-file.

To see the doc string of iswitchb for full keybindings and features, type:

 
  M-x describe-function RET iswitchb

5.1 Customization  
5.2 Changing the Display  
5.3 Regexp Matching  
5.4 Replacement for read-buffer  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1 Customization

To configure the package, type:

 
  M-x customize-group RET iswitchb RET

To install this package on the default keys used for buffer switching, type:

 
  M-x iswitchb-default-keybindings RET

To modify the default keybindings, use the hook provided. For example, the following code can be added to your initialization file:

 
  (add-hook 'iswitchb-define-mode-map-hook 'iswitchb-my-keys)

  (defun iswitchb-my-keys ()
    "Add my keybindings for iswitchb."
    (define-key iswitchb-mode-map " " 'iswitchb-next-match)
    )


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2 Changing the Display

If you have many matching buffers, they may not all fit onto one line of the minibuffer. In this case, you should use (resize-minibuffer-mode) See section 7. Self-Resizing Minibuffer. You can also limit iswitchb so that it only shows a certain number of lines. To do this, see the documentation for iswitchb-minibuffer-setup-hook.

By default, the list of current buffers is most recent first, oldest last, with the exception that the buffers visible in the current frame are put at the end of the list. A hook exists to allow other functions to order the list. For example, if you add:

 
  (add-hook 'iswitchb-make-buflist-hook 'iswitchb-summaries-to-end)

then all buffers matching "Summary" are moved to the end of the list. (I find this handy for keeping the INBOX Summary and so on out of the way.) It also moves buffers matching "output\*$" to the end of the list (these are created by AUC TeX when compiling.) Other functions could be made available which alter the list of matching buffers (either deleting or rearranging elements.)

If you have font-lock loaded, the first matching buffer is highlighted. To switch this off, set (setq iswitchb-use-fonts nil). I don't use font-lock that much, so I've hardcoded the faces. If this is too harsh, let me know. Colouring of the matching buffer name was suggested by Carsten Dominik (dominik@strw.leidenuniv.nl)


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.3 Regexp Matching

There is limited provision for regexp matching within iswitchb, enabled through iswitchb-regexp. This allows you to type c$ for example and see all buffer names ending in `c'. This facility is quite limited though in two respects. First, you can't currently type in expressions like `[0-9]' directly -- you have to type them in when iswitchb-regexp is nil and then toggle on the regexp functionality. Likewise, don't enter an expression containing `\' in regexp mode. If you try, iswitchb gets confused, so just hit C-g and try again. Secondly, no completion mechanism is currently offered when regexp searching.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4 Replacement for read-buffer

iswitchb-read-buffer has been written to be a drop in replacement for the normal buffer selection routine read-buffer. To use iswitch for all buffer selections in Emacs, add: (setq read-buffer-function 'iswitchb-read-buffer) (This variable should be present in Emacs 20.3+) XEmacs users can get the same behaviour by doing: (defalias 'read-buffer 'iswitchb-read-buffer) since read-buffer is defined in lisp.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by XEmacs shared group account on December, 19 2009 using texi2html 1.65.