Emacs: help me understand file/buffer management

  1. Bind C-x C-b to ibuffer. This is a better buffer listing facility with many advanced features, and its default behaviour is to replace the current buffer with the buffer listing, and then bury the listing when you select a buffer (leaving you with the newly-selected buffer in place of the original one).

    You can simply use C-x b to enter your selection in the mini-buffer, of course; however the tab-completion (which is needed to make this a viable option, IMO) does open a new window temporarily, at which point I think you might as well familiarise yourself with something with more features.

  2. Use a instead of RET when selecting from dired. This kills the dired buffer instead of leaving it behind. C-h m in any buffer will show you the help for its major mode (followed by help for the minor modes), and you can read about all the available dired key bindings there.

  3. http://www.emacswiki.org/cgi-bin/wiki/TabBarMode ? (edit: I prefer RĂ©mi’s answer for this one, but TabBarMode would give you the visual tab element if you were particularly keen on that.)

  4. q is bound to a ‘quit’ function in a great many major modes. Generally it buries the buffer rather than killing it, but I certainly find that fine.

To elaborate a little on #1, ibuffer has lots of nice features, and M-x customize-group ibuffer RET will give you some idea of how you can customise it to your liking.

Furthermore, you can filter the buffer list by many criteria (again, use C-h m to see its help page), and then generate a ‘group’ definition from the current filters, and save your custom filters and groups for future usage.

For example:

  • / f ^/var/www/ RET: filter buffer list to show only filenames starting with /var/www/.
  • / s Web filters RET: name and save active filter set to your init file.
  • / g Web development RET: create a named group from the active filters.
  • / S My groups RET: name and save group definitions to your init file.
  • / r Web filters RET: invoke the “Web filters” filters.
  • / R My groups RET: invoke the “My groups” groups.
  • RET on a group name to collapse or expand it.
  • C-k and C-y to kill and yank groups, to re-arrange them.
  • C-h m for more information…

This way you can have a single Emacs instance running, and create filters and groups for different types of task, and easily switch between them.

Leave a Comment