Address a few more byte-compiler warnings
[~bandali/configs] / lisp / bandali-ibuffer.el
1 ;;; bandali-ibuffer.el --- bandali's Ibuffer setup -*- lexical-binding: t; -*-
2
3 ;; Copyright (C) 2018-2020 Amin Bandali
4
5 ;; Author: Amin Bandali <bandali@gnu.org>
6 ;; Keywords: tools
7
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
12
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
20
21 ;;; Commentary:
22
23 ;; My Ibuffer setup.
24
25 ;;; Code:
26
27 (use-package ibuffer
28 :bind
29 (("C-x C-b" . ibuffer)
30 :map ibuffer-mode-map
31 ("P" . ibuffer-backward-filter-group)
32 ("N" . ibuffer-forward-filter-group)
33 ("M-p" . ibuffer-do-print)
34 ("M-n" . ibuffer-do-shell-command-pipe-replace))
35 :config
36 ;; Use human readable Size column instead of original one
37 (define-ibuffer-column size-h
38 (:name "Size" :inline t)
39 (cond
40 ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
41 ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0)))
42 ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
43 (t (format "%8d" (buffer-size)))))
44 (declare-function ibuffer-switch-to-saved-filter-groups "ibuf-ext"
45 (name))
46 :custom
47 (ibuffer-saved-filter-groups
48 '(("default"
49 ("dired" (mode . dired-mode))
50 ("org" (mode . org-mode))
51 ("gnus"
52 (or
53 (mode . gnus-group-mode)
54 (mode . gnus-summary-mode)
55 (mode . gnus-article-mode)
56 ;; not really, but...
57 (mode . message-mode)))
58 ("web"
59 (or
60 ;; (mode . web-mode)
61 (mode . mhtml-mode)
62 (mode . css-mode)
63 (mode . scss-mode)
64 (mode . js2-mode)))
65 ("shell"
66 (or
67 (mode . eshell-mode)
68 (mode . shell-mode)
69 (mode . term-mode)))
70 ("programming"
71 (or
72 (mode . python-mode)
73 (mode . c-mode)
74 (mode . c++-mode)
75 (mode . java-mode)
76 (mode . emacs-lisp-mode)
77 (mode . scheme-mode)
78 (mode . haskell-mode)
79 (mode . lean-mode)
80 ;; (mode . go-mode)
81 (mode . alloy-mode)))
82 ("tex"
83 (or
84 (mode . bibtex-mode)
85 (mode . latex-mode)))
86 ("emacs"
87 (or
88 (name . "^\\*scratch\\*$")
89 (name . "^\\*Messages\\*$")))
90 ("exwm" (mode . exwm-mode))
91 ("erc" (mode . erc-mode)))))
92 (ibuffer-formats
93 '((mark modified read-only locked " "
94 (name 72 72 :left :elide)
95 " "
96 (size-h 9 -1 :right)
97 " "
98 (mode 16 16 :left :elide)
99 " " filename-and-process)
100 (mark " "
101 (name 16 -1)
102 " " filename)))
103 :hook (ibuffer . (lambda () (ibuffer-switch-to-saved-filter-groups "default"))))
104
105 (provide 'bandali-ibuffer)
106 ;;; bandali-ibuffer.el ends here