summaryrefslogtreecommitdiff
path: root/lisp/ibuf-ext.el
diff options
context:
space:
mode:
authorIvan Andrus <darthandrus@gmail.com>2012-04-23 22:07:40 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2012-04-23 22:07:40 -0400
commitc4cf6d91f36ebd8d05109926d9e16ba02693cb9f (patch)
tree4edfbaf9968173bf0bc7a6458e7df633a7b8e7cb /lisp/ibuf-ext.el
parent02fd101be2379fabdc5c45bf9ebd890e7c4bc58f (diff)
downloademacs-c4cf6d91f36ebd8d05109926d9e16ba02693cb9f.tar.gz
* lisp/ibuf-ext.el (ibuffer-list-buffer-modes): Add `include-parents' arg.
(ibuffer-filter-by-derived-mode): New filter. * lisp/ibuffer.el (ibuffer-mode-map): Bind to `/ w'.
Diffstat (limited to 'lisp/ibuf-ext.el')
-rw-r--r--lisp/ibuf-ext.el24
1 files changed, 19 insertions, 5 deletions
diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el
index 22ec2f5df1f..dc90617f92e 100644
--- a/lisp/ibuf-ext.el
+++ b/lisp/ibuf-ext.el
@@ -973,8 +973,9 @@ Interactively, prompt for NAME, and use the current filters."
(concat " [" (cadr type) ": " (format "%s]" (cdr qualifier)))))))
-(defun ibuffer-list-buffer-modes ()
+(defun ibuffer-list-buffer-modes (&optional include-parents)
"Create an alist of buffer modes currently in use.
+If INCLUDE-PARENTS is non-nil then include parent modes.
The list returned will be of the form (\"MODE-NAME\" . MODE-SYMBOL)."
(let ((bufs (buffer-list))
(modes)
@@ -982,10 +983,13 @@ The list returned will be of the form (\"MODE-NAME\" . MODE-SYMBOL)."
(while bufs
(setq this-mode (buffer-local-value 'major-mode (car bufs))
bufs (cdr bufs))
- (add-to-list
- 'modes
- `(,(symbol-name this-mode) .
- ,this-mode)))
+ (while this-mode
+ (add-to-list
+ 'modes
+ `(,(symbol-name this-mode) .
+ ,this-mode))
+ (setq this-mode (and include-parents
+ (get this-mode 'derived-mode-parent)))))
modes))
@@ -1027,6 +1031,16 @@ currently used by buffers."
"")))))
(eq qualifier (buffer-local-value 'major-mode buf)))
+(define-ibuffer-filter derived-mode
+ "Toggle current view to buffers whose major mode inherits from QUALIFIER."
+ (:description "derived mode"
+ :reader
+ (intern
+ (completing-read "Filter by derived mode: "
+ (ibuffer-list-buffer-modes t)
+ nil nil "")))
+ (with-current-buffer buf (derived-mode-p qualifier)))
+
;;;###autoload (autoload 'ibuffer-filter-by-name "ibuf-ext")
(define-ibuffer-filter name
"Toggle current view to buffers with name matching QUALIFIER."