all repos — nixfiles @ eb896949d088a8429c5521279edf0479bf44453a

System and user configuration, managed by nix and home-manager

Emacs: group buffers in ibuffer by project, showing relative path
Alan Pearce alan@alanpearce.eu
Sun, 06 Aug 2023 20:05:34 +0200
commit

eb896949d088a8429c5521279edf0479bf44453a

parent

74cd2f42bdac28b252944c52491781b4d3d2c201

2 files changed, 16 insertions(+), 0 deletions(-)

jump to
M user/emacs/init.eluser/emacs/init.el
@@ -925,6 +925,21 @@ (evil-ex-define-cmd "pesh[ell]" #'project-eshell)               (evil-ex-define-cmd "pb" #'project-switch-to-buffer)
               (evil-ex-define-cmd "psw[itch]" #'project-switch-project))))
 
+(use-package ibuffer-project
+  :config (progn
+            (defun ibuffer-project-set-filter-groups ()
+               (setq ibuffer-filter-groups (ibuffer-project-generate-filter-groups))
+               (unless (eq ibuffer-sorting-mode 'project-file-relative)
+                 (ibuffer-do-sort-by-project-file-relative)))
+            (add-hook 'ibuffer-hook #'ibuffer-project-set-filter-groups)
+            (add-to-list 'ibuffer-project-root-functions '(file-remote-p . "Remote"))
+            (setq ibuffer-formats '((mark modified read-only locked " "
+                                          (name 18 18 :left :elide)
+                                          " "
+                                          (size 9 -1 :right)
+                                          " "
+                                          (mode 16 16 :left :elide)
+                                          " " project-file-relative)))))
 (use-package consult-ghq
   :defer 5
   :general (:keymaps 'project-prefix-map
M user/settings/emacs.nixuser/settings/emacs.nix
@@ -149,6 +149,7 @@ git-modes         git-timemachine
         goto-chg
         helpful
+        ibuffer-project
         jinx
         just-mode
         justl