diff --git a/config/ibuffer/config-ibuffer-filter-groups.el b/config/ibuffer/config-ibuffer-filter-groups.el new file mode 100644 index 0000000..89f60e3 --- /dev/null +++ b/config/ibuffer/config-ibuffer-filter-groups.el @@ -0,0 +1,8 @@ +(setq ibuffer-saved-filter-groups + '(("default" + ("misc" (name . "^\\*.*$")) + ("dired" (mode . dired-mode))))) + +(add-hook 'ibuffer-mode-hook (lambda () (ibuffer-switch-to-saved-filter-groups "default"))) + +(provide 'config-ibuffer-filter-groups) diff --git a/config/ibuffer/config-ibuffer-human-readable-size.el b/config/ibuffer/config-ibuffer-human-readable-size.el new file mode 100644 index 0000000..5cec3a9 --- /dev/null +++ b/config/ibuffer/config-ibuffer-human-readable-size.el @@ -0,0 +1,16 @@ +(define-ibuffer-column size-human-readable + (:name "Size" :inline t) + (let ((size (buffer-size))) + (cond + ((> size (expt 1000 4)) + (error "buffer is over 1TB large!")) + ((> size (expt 1000 3)) + (format "%sG" (/ size (expt 1000 3)))) + ((> size (expt 1000 2)) + (format "%sM" (/ size (expt 1000 2)))) + ((> size 1000) + (format "%sK" (/ size 1000))) + (t + (format "%sB" size))))) + +(provide 'config-ibuffer-human-readable-size) diff --git a/config/ibuffer/config-ibuffer-never-show.el b/config/ibuffer/config-ibuffer-never-show.el new file mode 100644 index 0000000..f21554f --- /dev/null +++ b/config/ibuffer/config-ibuffer-never-show.el @@ -0,0 +1,11 @@ +(defvar config-ibuffer-never-show '("^\\*Messages\\*$" + "^\\*Help\\*$" + "^\\*Completions\\*$" + "^\\*Backtrace\\*$" + "^\\*Async-native-compile-log\\*$")) + +(mapc (lambda (p) + (add-to-list 'ibuffer-never-show-predicates p)) + config-ibuffer-never-show) + +(provide 'config-ibuffer-never-show) diff --git a/config/ibuffer/config-ibuffer.el b/config/ibuffer/config-ibuffer.el new file mode 100644 index 0000000..ddc104d --- /dev/null +++ b/config/ibuffer/config-ibuffer.el @@ -0,0 +1,22 @@ +(require 'ibuffer) +(require 'ibuf-ext) +(require 'config-ibuffer-human-readable-size) +(require 'config-ibuffer-never-show) +(require 'config-ibuffer-filter-groups) + +(setq ibuffer-display-summary nil + ibuffer-expert t) + +(setq ibuffer-formats + '((mark modified read-only locked " " + (name 18 18 :left :elide) + " " + (size-human-readable 5 5 :right) + " " + (mode 16 16 :left :elide) + " " filename-and-process) + (mark " " + (name 16 -1) + " " filename))) + +(provide 'config-ibuffer) diff --git a/config/keys/config-keys.el b/config/keys/config-keys.el index 6d74b0a..286521c 100644 --- a/config/keys/config-keys.el +++ b/config/keys/config-keys.el @@ -7,5 +7,6 @@ (global-unset-key (kbd "")) (global-unset-key (kbd "")) (global-set-key (kbd "C-x k") 'kill-buffer) +(global-set-key (kbd "C-x C-b") 'ibuffer) (provide 'config-keys) diff --git a/load-config.el b/load-config.el index 4e34a2d..231787d 100644 --- a/load-config.el +++ b/load-config.el @@ -9,6 +9,7 @@ (add-to-list 'load-path (file-name-concat config-directory "flycheck")) (add-to-list 'load-path (file-name-concat config-directory "flymake")) (add-to-list 'load-path (file-name-concat config-directory "garbage-collection")) + (add-to-list 'load-path (file-name-concat config-directory "ibuffer")) (add-to-list 'load-path (file-name-concat config-directory "keys")) (add-to-list 'load-path (file-name-concat config-directory "man")) (add-to-list 'load-path (file-name-concat config-directory "lsp-mode")) @@ -30,6 +31,7 @@ (require 'config-electric) (require 'config-flymake) (require 'config-garbage-collection) +(require 'config-ibuffer) (require 'config-keys) (require 'config-man) (require 'config-package)