diff options
author | JSDurand <mmemmew@gmail.com> | 2021-06-01 18:07:30 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2021-06-01 18:07:30 +0800 |
commit | eef71477ce8484a1faeacb28de1a71ee4365eda7 (patch) | |
tree | eceab27acbd9f6415aef27130a8b08c1fcc78bd2 | |
parent | 0c6f3a8619db823e5918343f4f8cabcfcedb1cba (diff) |
Add a key-binding to clear buffers in ibuffer.
* ibuffer.el (durand-ibuffer-clear): This is my frequent operation.
(ibuffer-mode-map): Bind to a key.
-rw-r--r-- | ibuffer.el | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -73,6 +73,41 @@ If the optional ARG is non-nil, then produce an IBUFFER buffer (list (cons 'used-mode (buffer-local-value 'major-mode (current-buffer)))))))) +;;;###autoload +(defun durand-ibuffer-clear (&optional arg) + "Kill every buffer except for the dashboard. +If the optional ARG is non-nil, then kill every buffer except for +those that are marked." + (interactive "P") + (cond + ((derived-mode-p 'ibuffer-mode)) + ((user-error "durand-ibuffer-clear should only be used in \ +derived modes of ibuffer-mode."))) + (cond + ((null arg) + (mapc (function + (lambda (buffer) + (cond + ((string= (buffer-name buffer) + dashboard-buffer-name)) + ((kill-buffer buffer))))) + (cons + (current-buffer) + (mapcar #'car (ibuffer-current-state-list))))) + (t + (mapc (function + (lambda (buffer-and-mark) + (cond + ((or (/= (cdr buffer-and-mark) + ibuffer-marked-char) + (string= (buffer-name (car buffer-and-mark)) + dashboard-buffer-name))) + ((kill-buffer (car buffer-and-mark)))))) + (cons + (cons (current-buffer) 32) + (ibuffer-current-state-list))) + (ibuffer-update nil)))) + (define-key global-map (vector 24 2) #'ibuffer) (define-key global-map (vector ?\s-h) #'ibuffer) (define-key global-map (vector ?\M-\s-b) #'switch-to-buffer-same-mode) @@ -83,6 +118,7 @@ If the optional ARG is non-nil, then produce an IBUFFER buffer (define-key ibuffer-mode-map (vector ?d) #'ibuffer-do-delete) (define-key ibuffer-mode-map (vector ?D) #'ibuffer-mark-for-delete) +(define-key ibuffer-mode-map (vector ?c) #'durand-ibuffer-clear) ;;; filter for bongo |