emacs ido-buffer:按目录分组缓冲区

时间:2014-05-28 04:28:59

标签: emacs ido

是否可以在某种树形表示中查看buffersdirectories分组的开放emacs ido-buffer mode

1 个答案:

答案 0 :(得分:1)

" emacs ido-buffer mode" ??

您的意思是ibuffer吗?如果是的话......

它不是分组 1 ,但按文件名排序是一个相当有用的近似值,默认情况下可用。

取值 ˚F

不幸的是(在我看来)没有包括dired缓冲区。您可以通过定义包含它们的分拣机变体,然后重新映射绑定来解决这个问题:

(eval-after-load 'ibuffer
  '(progn
     (define-ibuffer-sorter filename/directory/process
       "Sort the buffers by their file name/process name."
       (:description "file name")
       (string-lessp
        (or (buffer-file-name (car a))
            (let ((dir (buffer-local-value 'dired-directory (car a))))
              (if (consp dir) (car dir) dir))
            (let ((pr-a (get-buffer-process (car a))))
              (and (processp pr-a) (process-name pr-a))))
        (or (buffer-file-name (car b))
            (let ((dir (buffer-local-value 'dired-directory (car b))))
              (if (consp dir) (car dir) dir))
            (let ((pr-b (get-buffer-process (car b))))
              (and (processp pr-b) (process-name pr-b))))))

     (define-key ibuffer-mode-map
       [remap ibuffer-do-sort-by-filename/process]
       'ibuffer-do-sort-by-filename/directory/process)))

1 按目录动态分组的功能非常好。