reformat 'File' field in emacs buffer list?
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 ?
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)
This might also help, though it does not address your question directly: Buffer Menu+.
- You can use + and - to resize the - Bufferand- Sizecolumns, giving more space to the other columns.
- You can toggle the display of columns - Timeand- Mode, to give other columns more space. (You can also toggle the- Timeformat, making it shorter without removing it.)
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论