Add Tridactyl config
[~bandali/configs] / lisp / bandali-ibuffer.el
1 (use-package ibuffer
2 :bind
3 (("C-x C-b" . ibuffer)
4 :map ibuffer-mode-map
5 ("P" . ibuffer-backward-filter-group)
6 ("N" . ibuffer-forward-filter-group)
7 ("M-p" . ibuffer-do-print)
8 ("M-n" . ibuffer-do-shell-command-pipe-replace))
9 :config
10 ;; Use human readable Size column instead of original one
11 (define-ibuffer-column size-h
12 (:name "Size" :inline t)
13 (cond
14 ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
15 ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0)))
16 ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
17 (t (format "%8d" (buffer-size)))))
18 :custom
19 (ibuffer-saved-filter-groups
20 '(("default"
21 ("dired" (mode . dired-mode))
22 ("org" (mode . org-mode))
23 ("gnus"
24 (or
25 (mode . gnus-group-mode)
26 (mode . gnus-summary-mode)
27 (mode . gnus-article-mode)
28 ;; not really, but...
29 (mode . message-mode)))
30 ("web"
31 (or
32 ;; (mode . web-mode)
33 (mode . mhtml-mode)
34 (mode . css-mode)
35 (mode . scss-mode)
36 (mode . js2-mode)))
37 ("shell"
38 (or
39 (mode . eshell-mode)
40 (mode . shell-mode)
41 (mode . term-mode)))
42 ("programming"
43 (or
44 (mode . python-mode)
45 (mode . c-mode)
46 (mode . c++-mode)
47 (mode . java-mode)
48 (mode . emacs-lisp-mode)
49 (mode . scheme-mode)
50 (mode . haskell-mode)
51 (mode . lean-mode)
52 ;; (mode . go-mode)
53 (mode . alloy-mode)))
54 ("tex"
55 (or
56 (mode . bibtex-mode)
57 (mode . latex-mode)))
58 ("emacs"
59 (or
60 (name . "^\\*scratch\\*$")
61 (name . "^\\*Messages\\*$")))
62 ("exwm" (mode . exwm-mode))
63 ("erc" (mode . erc-mode)))))
64 (ibuffer-formats
65 '((mark modified read-only locked " "
66 (name 72 72 :left :elide)
67 " "
68 (size-h 9 -1 :right)
69 " "
70 (mode 16 16 :left :elide)
71 " " filename-and-process)
72 (mark " "
73 (name 16 -1)
74 " " filename)))
75 :hook (ibuffer . (lambda () (ibuffer-switch-to-saved-filter-groups "default"))))
76
77 (provide 'bandali-ibuffer)