Commit d81bd059 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

* lisp/ibuffer.el (ibuffer-mode-map): Bind `/ m' to filter-used-mode

and `/ M' to filter-derived-mode.
* lisp/ibuf-ext.el (ibuffer-list-buffer-modes): Simplify; avoid add-to-list.
(ibuffer-filter-by-mode, ibuffer-filter-by-used-mode)
(ibuffer-mark-by-mode): Use default rather than initial-input.
(ibuffer-filter-by-derived-mode): Autoload and require-match.
parent c4cf6d91
......@@ -74,7 +74,8 @@ character when doing minibuffer filename prompts.
* Changes in Specialized Modes and Packages in Emacs 24.2
** New `derived-mode' filter for Ibuffer, bound to `/ w'.
** New `derived-mode' filter for Ibuffer, bound to `/ M'.
`/ m' is now bound to filter by used-mode, which used to be bound to `/ M'.
** Apropos
......
2012-04-24 Stefan Monnier <monnier@iro.umontreal.ca>
* ibuffer.el (ibuffer-mode-map): Bind `/ m' to filter-used-mode
and `/ M' to filter-derived-mode.
* ibuf-ext.el (ibuffer-list-buffer-modes): Simplify; avoid add-to-list.
(ibuffer-filter-by-mode, ibuffer-filter-by-used-mode)
(ibuffer-mark-by-mode): Use default rather than initial-input.
(ibuffer-filter-by-derived-mode): Autoload and require-match.
2012-04-24 Ivan Andrus <darthandrus@gmail.com> (tiny change)
* ibuf-ext.el (ibuffer-list-buffer-modes): Add `include-parents' arg.
......
......@@ -974,23 +974,16 @@ Interactively, prompt for NAME, and use the current filters."
(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)
(this-mode))
(while bufs
(setq this-mode (buffer-local-value 'major-mode (car bufs))
bufs (cdr bufs))
(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))
"Create a completion table of buffer modes currently in use.
If INCLUDE-PARENTS is non-nil then include parent modes."
(let ((modes))
(dolist (buf (buffer-list))
(let ((this-mode (buffer-local-value 'major-mode buf)))
(while (and this-mode (not (memq this-mode modes)))
(push this-mode modes)
(setq this-mode (and include-parents
(get this-mode 'derived-mode-parent))))))
(mapcar #'symbol-name modes)))
;;; Extra operation definitions
......@@ -1000,16 +993,19 @@ The list returned will be of the form (\"MODE-NAME\" . MODE-SYMBOL)."
"Toggle current view to buffers with major mode QUALIFIER."
(:description "major mode"
:reader
(intern
(completing-read "Filter by major mode: " obarray
#'(lambda (e)
(string-match "-mode$"
(symbol-name e)))
t
(let ((buf (ibuffer-current-buffer)))
(if (and buf (buffer-live-p buf))
(symbol-name (buffer-local-value 'major-mode buf))
"")))))
(let* ((buf (ibuffer-current-buffer))
(default (if (and buf (buffer-live-p buf))
(symbol-name (buffer-local-value
'major-mode buf)))))
(intern
(completing-read
(if default
(format "Filter by major mode (default %s): " default)
"Filter by major mode: ")
obarray
#'(lambda (e)
(string-match "-mode\\'" (symbol-name e)))
t nil nil default))))
(eq qualifier (buffer-local-value 'major-mode buf)))
;;;###autoload (autoload 'ibuffer-filter-by-used-mode "ibuf-ext")
......@@ -1018,19 +1014,20 @@ The list returned will be of the form (\"MODE-NAME\" . MODE-SYMBOL)."
Called interactively, this function allows selection of modes
currently used by buffers."
(:description "major mode in use"
:reader
(intern
(completing-read "Filter by major mode: "
(ibuffer-list-buffer-modes)
nil
t
(let ((buf (ibuffer-current-buffer)))
(if (and buf (buffer-live-p buf))
(symbol-name (buffer-local-value
'major-mode buf))
"")))))
:reader
(let* ((buf (ibuffer-current-buffer))
(default (if (and buf (buffer-live-p buf))
(symbol-name (buffer-local-value
'major-mode buf)))))
(intern
(completing-read
(if default
(format "Filter by major mode (default %s): " default)
"Filter by major mode: ")
(ibuffer-list-buffer-modes) nil t nil nil default))))
(eq qualifier (buffer-local-value 'major-mode buf)))
;;;###autoload (autoload 'ibuffer-filter-by-derived-mode "ibuf-ext")
(define-ibuffer-filter derived-mode
"Toggle current view to buffers whose major mode inherits from QUALIFIER."
(:description "derived mode"
......@@ -1038,7 +1035,7 @@ currently used by buffers."
(intern
(completing-read "Filter by derived mode: "
(ibuffer-list-buffer-modes t)
nil nil "")))
nil t)))
(with-current-buffer buf (derived-mode-p qualifier)))
;;;###autoload (autoload 'ibuffer-filter-by-name "ibuf-ext")
......@@ -1480,19 +1477,16 @@ You can then feed the file name(s) to other commands with \\[yank]."
(defun ibuffer-mark-by-mode (mode)
"Mark all buffers whose major mode equals MODE."
(interactive
(list (intern (completing-read "Mark by major mode: " obarray
#'(lambda (e)
;; kind of a hack...
(and (fboundp e)
(string-match "-mode$"
(symbol-name e))))
t
(let ((buf (ibuffer-current-buffer)))
(if (and buf (buffer-live-p buf))
(with-current-buffer buf
(cons (symbol-name major-mode)
0))
""))))))
(let* ((buf (ibuffer-current-buffer))
(default (if (and buf (buffer-live-p buf))
(symbol-name (buffer-local-value
'major-mode buf)))))
(list (intern
(completing-read
(if default
(format "Mark by major mode (default %s): " default)
"Mark by major mode: ")
(ibuffer-list-buffer-modes) nil t nil nil default)))))
(ibuffer-mark-on-buffer
#'(lambda (buf)
(eq (buffer-local-value 'major-mode buf) mode))))
......
......@@ -501,9 +501,8 @@ directory, like `default-directory'."
(define-key map (kbd "s f") 'ibuffer-do-sort-by-filename/process)
(define-key map (kbd "s m") 'ibuffer-do-sort-by-major-mode)
(define-key map (kbd "/ m") 'ibuffer-filter-by-mode)
(define-key map (kbd "/ M") 'ibuffer-filter-by-used-mode)
(define-key map (kbd "/ w") 'ibuffer-filter-by-derived-mode)
(define-key map (kbd "/ m") 'ibuffer-filter-by-used-mode)
(define-key map (kbd "/ M") 'ibuffer-filter-by-derived-mode)
(define-key map (kbd "/ n") 'ibuffer-filter-by-name)
(define-key map (kbd "/ c") 'ibuffer-filter-by-content)
(define-key map (kbd "/ e") 'ibuffer-filter-by-predicate)
......@@ -2646,7 +2645,7 @@ will be inserted before the group at point."
;;;;;; ibuffer-backward-filter-group ibuffer-forward-filter-group
;;;;;; ibuffer-toggle-filter-group ibuffer-mouse-toggle-filter-group
;;;;;; ibuffer-interactive-filter-by-mode ibuffer-mouse-filter-by-mode
;;;;;; ibuffer-auto-mode) "ibuf-ext" "ibuf-ext.el" "b2b8f11ad22546ad05d6db0b7d388ac1")
;;;;;; ibuffer-auto-mode) "ibuf-ext" "ibuf-ext.el" "98491557b04909791f687f2eecc88320")
;;; Generated autoloads from ibuf-ext.el
(autoload 'ibuffer-auto-mode "ibuf-ext" "\
......@@ -2836,6 +2835,7 @@ Set this buffer's filters to filters with NAME from `ibuffer-saved-filters'.
\(fn NAME)" t nil)
(autoload 'ibuffer-filter-by-mode "ibuf-ext")
(autoload 'ibuffer-filter-by-used-mode "ibuf-ext")
(autoload 'ibuffer-filter-by-derived-mode "ibuf-ext")
(autoload 'ibuffer-filter-by-name "ibuf-ext")
(autoload 'ibuffer-filter-by-filename "ibuf-ext")
(autoload 'ibuffer-filter-by-size-gt "ibuf-ext")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment