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 community
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)
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.
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.
Using projectile, you can simply type C-c p I (projectile-ibuffer) and only the buffers for that project will show up in ibuffer.