From: Ivan Andrus <darthandrus@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 11295@debbugs.gnu.org
Subject: bug#11295: 24.0.95; New ibuffer filter derived-mode
Date: Mon, 23 Apr 2012 20:51:21 +0200 [thread overview]
Message-ID: <B33A2C01-AE70-41F3-8C89-95B73755BF24@gmail.com> (raw)
In-Reply-To: <jwvliloq3bh.fsf-monnier+emacs@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1104 bytes --]
On Apr 21, 2012, at 9:44 PM, Stefan Monnier wrote:
>>> Why not use (with-current-buffer buf (derived-mode-p parent))?
>> Uh. That would have been too easy. :-)
>
> I can relate to that.
>
>>> Another question: couldn't it simply *replace* the existing mode filter?
>>> I guess it could be a bit annoying if you want to see fundamental-mode
>>> buffers (since most modes derive from it), but that's the only downside
>>> I can think of.
>> I thought about it, but I do in fact filter by fundamental-mode (and a few
>> other modes) to hide "useless" buffers.
>
> Fair enough. Please send us an updated patch, so we can install it,
Attached is an updated patch. I also added a keybinding, though I'm not entirely happy with it. I chose / w since w is an upside down m. My first choices of m, M, p, P, d, and D were all taken. They were for mode, parent, and derived. Feel free to ignore or change that portion. Perhaps the key should replace one of the current mode filter keys m and M.
FWIW, I contacted assign@gnu.org for some changes in expand-region.el.
-Ivan
[-- Attachment #2: ibuffer.patch --]
[-- Type: application/octet-stream, Size: 2088 bytes --]
=== modified file 'lisp/ibuf-ext.el'
--- lisp/ibuf-ext.el 2012-01-19 07:21:25 +0000
+++ lisp/ibuf-ext.el 2012-04-23 17:58:13 +0000
@@ -973,8 +973,9 @@
(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 @@
(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 @@
"")))))
(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."
=== modified file 'lisp/ibuffer.el'
--- lisp/ibuffer.el 2012-03-12 02:41:22 +0000
+++ lisp/ibuffer.el 2012-04-23 16:04:06 +0000
@@ -504,6 +504,7 @@
(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 "/ n") 'ibuffer-filter-by-name)
(define-key map (kbd "/ c") 'ibuffer-filter-by-content)
(define-key map (kbd "/ e") 'ibuffer-filter-by-predicate)
next prev parent reply other threads:[~2012-04-23 18:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-21 11:11 bug#11295: 24.0.95; New ibuffer filter derived-mode Ivan Andrus
2012-04-21 14:24 ` Stefan Monnier
2012-04-21 15:24 ` Ivan Andrus
2012-04-21 19:44 ` Stefan Monnier
2012-04-23 18:51 ` Ivan Andrus [this message]
2012-04-24 3:46 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=B33A2C01-AE70-41F3-8C89-95B73755BF24@gmail.com \
--to=darthandrus@gmail.com \
--cc=11295@debbugs.gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.