I'd like to group my buffer list in ibuffer by project. Project is meant in the Projectile sense of the word.
I don't want to change my Emacs configuration every time I'm working on a new project. Is there a way to achieve this automatically?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityI'd like to group my buffer list in ibuffer by project. Project is meant in the Projectile sense of the word.
I don't want to change my Emacs configuration every time I'm working on a new project. Is there a way to achieve this automatically?
You can define filter groups for known projects using something like this:
;; Define ibuffer filter groups for each known project
(defun my/define-projectile-filter-groups ()
(when (boundp 'projectile-known-projects)
(setq my/project-filter-groups
(mapcar
(lambda (it)
(let ((name (file-name-nondirectory (directory-file-name it))))
`(,name (filename . ,(expand-file-name it)))))
projectile-known-projects))))
;; Set up default ibuffer filter groups
(setq ibuffer-saved-filter-groups
(list
(cons "default"
(append
(my/define-projectile-filter-groups)
;; ... whatever other groups you want, e.g.
'(("dired" (mode . dired-mode))
("erc" (mode . erc-mode)))
))))
;; Enable default groups by default
(add-hook 'ibuffer-mode-hook
(lambda ()
(ibuffer-switch-to-saved-filter-groups "default")))
;; You probably don't want to see empty project groups
(setq ibuffer-show-empty-filter-groups nil)
Update
Since I originally wrote this answer, @sanityinc has created a variant of ibuffer-vc
that creates filter groups by projectile project root. You can find ibuffer-projectile
on MELPA or on GitHub.
projectile-switch-buffer
. Ibuffer is meant for managing large amount of buffers, and that's why it has grouping and filtering. I like the current approach that it groups based on known project list, making it more consistent with Projectile.
– Tu Do
Oct 18 '14 at 16:13
Project is meant in the Projectile sense of the word.
Using Projectile, there is a way to switch to a buffer inside a specific project C-c p b
May I suggest ibuffer-vc? A way to group your buffers by their parent vc root directory.
ibuffer-vc
is pretty near to what I'm looking for. But it overwrites my ibuffer-saved-filter-groups
; is there a way to create the VC groups additionally to my standard groups?
– ckruse
Oct 15 '14 at 7:24
nox/ibuffer-apply-filter-groups
.
– tirocinium
May 12 '17 at 12:33
Using projectile, you can simply type C-c p I (projectile-ibuffer) and only the buffers for that project will show up in ibuffer.