bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#11295: 24.0.95; New ibuffer filter derived-mode


From: Stefan Monnier
Subject: bug#11295: 24.0.95; New ibuffer filter derived-mode
Date: Sat, 21 Apr 2012 10:24:54 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.94 (gnu/linux)

>   (define-ibuffer-filter derived-mode
>       "Toggle current view to buffers whose major mode inherits from 
> QUALIFIER."
>     (:description "major mode"
>                   :reader
>                   (intern
>                    (completing-read "Filter by major mode: " obarray
>                                     #'(lambda (e)
>                                         (string-match "-mode$"
>                                                       (symbol-name e)))

This completion table doesn't sound very good.  Much better would be to
collect all major modes in use and all their parents.

>                                     t
>                                     (let ((buf (ibuffer-current-buffer)))
>                                       (if (and buf (buffer-live-p buf))
>                                           (symbol-name (buffer-local-value 
> 'major-mode buf))
>                                         "")))))
>     (let ((parent (buffer-local-value 'major-mode buf)))
>       (while (and (not (eq parent qualifier))
>                   (setq parent (get parent 'derived-mode-parent))))
>       (eq parent qualifier)))

Why not use (with-current-buffer buf (derived-mode-p parent))?

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.


        Stefan





reply via email to

[Prev in Thread] Current Thread [Next in Thread]