summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ibuffer.el58
1 files changed, 50 insertions, 8 deletions
diff --git a/ibuffer.el b/ibuffer.el
index 93f6ccd..e1cf4ec 100644
--- a/ibuffer.el
+++ b/ibuffer.el
@@ -3,8 +3,8 @@
(require 'ibuffer)
(require 'ibuf-ext)
-(setq ibuffer-expert t
- ibuffer-display-summary nil)
+(setq ibuffer-expert t)
+(setq ibuffer-display-summary nil)
(setq ibuffer-show-empty-filter-groups nil)
@@ -74,22 +74,40 @@ If the optional ARG is non-nil, then produce an IBUFFER buffer
(buffer-local-value 'major-mode (current-buffer))))))))
;;;###autoload
+(defvar durand-clear-passlist nil
+ "The list of buffers that should not be deleted \
+automatically.")
+
+;; from dashboard.el
+(defvar dashboard-buffer-name)
+
+(cond
+ ((null dashboard-buffer-name)
+ (setq dashboard-buffer-name "")))
+
+(setq durand-clear-passlist
+ (list dashboard-buffer-name
+ "*Group*"
+ ".newsrc-dribble"))
+
+;;;###autoload
(defun durand-ibuffer-clear (&optional arg)
- "Kill every buffer except for the dashboard.
+ "Kill every buffer except for those in `durand-clear-passlist'.
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.")))
+derived modes of `ibuffer-mode'.")))
(cond
((null arg)
(mapc (function
(lambda (buffer)
(cond
- ((string= (buffer-name buffer)
- dashboard-buffer-name))
+ ((durand-member (buffer-name buffer)
+ durand-clear-passlist
+ #'string=))
((kill-buffer buffer)))))
(cons
(current-buffer)
@@ -144,12 +162,36 @@ derived modes of ibuffer-mode.")))
((derived-mode-p 'bongo-playlist-mode 'bongo-library-mode)))))
;;;###autoload
+(define-ibuffer-filter durand-directory
+ "Limit current view to buffers with directory a subdirectory of \
+QUALIFIER.
+
+For a buffer not associated with a file, this matches against the
+value of `default-directory' in that buffer."
+ (:description "directory name"
+ :reader (read-from-minibuffer "Filter by directory name (regex): "))
+ (ibuffer-aif (with-current-buffer buf (ibuffer-buffer-file-name))
+ (let ((dirname (expand-file-name (file-name-directory it))))
+ (when dirname
+ (string-match-p
+ (expand-file-name qualifier)
+ dirname)))
+ (when (with-current-buffer buf default-directory)
+ (string-match-p (expand-file-name qualifier)
+ (expand-file-name
+ (with-current-buffer buf
+ default-directory))))))
+
+;;;###autoload
(defun durand-bongo-set-filter ()
"Set my custom filters."
(interactive)
(setq ibuffer-filter-groups
- (cons (cons "Bongo" '((durand-bongo)))
- ibuffer-filter-groups))
+ (list (cons "Bongo" '((durand-bongo)))
+ (cons "C" '((mode . c-mode)))
+ (cons "ELisp" '((mode . emacs-lisp-mode)))
+ (cons "EWW" '((mode . eww-mode)))
+ (cons "Roman" '((mode . novel-read-mode)))))
(let ((ibuf (get-buffer "*Ibuffer*")))
(when ibuf
(with-current-buffer ibuf