emacs-ibuffer-project
emacs-ibuffer-project copied to clipboard
Group ibuffer's list by project
emacs-ibuffer-project
Emacs package that provides ibuffer filtering and sorting functions to group buffers by custom functions or regexps. By default buffers are grouped by project or by default directory.
Usage
To group buffers set ibuffer-filter-groups
to result of ibuffer-project-generate-filter-groups
function:
(add-hook
'ibuffer-hook
(lambda ()
(setq ibuffer-filter-groups (ibuffer-project-generate-filter-groups))
(unless (eq ibuffer-sorting-mode 'project-file-relative)
(ibuffer-do-sort-by-project-file-relative))))
Custom groups
Creating custom groups is possible by customizing ibuffer-project-root-functions
. For example, add function file-remote-p
like this:
(add-to-list 'ibuffer-project-root-functions '(file-remote-p . "Remote"))
In this case all remote buffers will be grouped by a string identifying the remote connection.
Project relative filename
This package also provides column with filename relative to project. If there are no file in buffer then column will display buffer name.
Add project-file-relative
to ibuffer-formats
:
(custom-set-variables
'(ibuffer-formats
'((mark modified read-only locked " "
(name 18 18 :left :elide)
" "
(size 9 -1 :right)
" "
(mode 16 16 :left :elide)
" " project-file-relative))))
It's also possible to sort buffers by that column by calling ibuffer-do-sort-by-project-file-relative
or:
(add-hook 'ibuffer-hook
(lambda ()
(setq ibuffer-filter-groups (ibuffer-project-generate-filter-groups))
(unless (eq ibuffer-sorting-mode 'project-file-relative)
(ibuffer-do-sort-by-project-file-relative))))
Caching project per directory
To avoid calling project-current
each time, one can set ibuffer-project-use-cache
. Project info will be stored in the ibuffer-project-cache
variable. Command ibuffer-project-clear-cache
allows to clear project info cache.
Installation
With package.el
ibuffer-project
available on MELPA:
M-x package-install
RET ibuffer-project
RET.
Alternatively, you can download ibuffer-project.el
and run:
M-x package-install-file
RET <path-to-ibuffer-project-el>
RET