tags:

views:

34

answers:

1

Context: using the Buffer List in Emacs to see what I'm doing, choose a buffer to visit, etc. FYI, I use fairly deep (sub-)directory organization to organize my files.

When I have lots of files open from the same subdirectory, the 'File' field mostly shows the part of the pathname that is the same for all files, i.e. the first 2-3 layers in my hierarchy of directories. So it gives me high-level info that's not very useful. The 'Buffer' field shows me the filename. That gives me low-level info that's too specific.

Is there a way to reformat the 'File' field to show me the most useful part of the file's path, i.e. the last couple of sub-directories the file is contained in and the filename? Literally, maybe the last characters of the path, instead of the first ?

+1  A: 

I prefer ibuffer for this sort of thing over buffer-menu. It allows you to group the file names by their name.

For instance, I have this in my .emacs (stolen from emacs-fu for the most part).

(require 'ibuffer) 
(setq ibuffer-saved-filter-groups
  (quote (("default"      
           ("MyProject"
            (filename . "/path/to/my/project/"))
           ("Programming"
            (or
             (mode . sh-mode)                 
             (mode . c-mode)
             (mode . cperl-mode)
             (mode . python-mode)
             (mode . emacs-lisp-mode)

             ;; etc
             ))
           ("Org" ;; all org-related buffers
            (mode . org-mode))                 
           ("ERC"
            (mode . erc-mode))
           ("Jabber"
            (or  ;; jabber-related buffers
             (mode . jabber-chat-mode)
             (mode . jabber-mode)
             (mode . jabber-roster-mode)
             ;; etc.; all your mail related modes
             ))))))

(add-hook 'ibuffer-mode-hook
      (lambda ()
        (ibuffer-switch-to-saved-filter-groups "default")))

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