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?

3 Answers 3


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
         (lambda (it)
           (let ((name (file-name-nondirectory (directory-file-name it))))
             `(,name (filename . ,(expand-file-name it)))))

;; Set up default ibuffer filter groups
(setq ibuffer-saved-filter-groups
       (cons "default"
              ;; ... 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)


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.

  • This is exaktly what I've been looking for, thanks!
    – ckruse
    Oct 16, 2014 at 7:23
  • This could be merged into Projectile.
    – Tu Do
    Oct 16, 2014 at 8:43
  • Yes, I should submit a pull request to support ibuffer groups. It came up once before but I didn't follow up. :D I'll take a closer look, it might make more sense to do something like ibuffer-vc and build the groups based on current buffers rather than the known project list. But a simple option would be to have projectile define a named filter group from known projects as shown here.
    – glucas
    Oct 16, 2014 at 14:27
  • As @Silex noted in another answer, someone already added ibuffer support earlier this year -- I had missed that. It's a different approach in that it filters ibuffer for the current project only, but looks handy.
    – glucas
    Oct 16, 2014 at 14:35
  • @glucas well but I think the current Ibuffer behaviors in Projectile is redundant with 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, 2014 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, 2014 at 7:24
  • @ckruse do not know; let me dig please.
    – Nsukami _
    Oct 15, 2014 at 12:38
  • This might help: github.com/reinh/dotemacs/blob/master/conf/init.org#ido. Specifically the part beginning nox/ibuffer-apply-filter-groups.
    – tirocinium
    May 12, 2017 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.