summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ibuffer.el36
1 files changed, 36 insertions, 0 deletions
diff --git a/ibuffer.el b/ibuffer.el
index 8d77296..a6910d0 100644
--- a/ibuffer.el
+++ b/ibuffer.el
@@ -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