[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#11295: 24.0.95; New ibuffer filter derived-mode
From: |
Ivan Andrus |
Subject: |
bug#11295: 24.0.95; New ibuffer filter derived-mode |
Date: |
Sat, 21 Apr 2012 17:24:58 +0200 |
On Apr 21, 2012, at 4:24 PM, Stefan Monnier wrote:
>> (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.
That is a much better idea. As I said, I just copy/pasted without thinking too
much. My main use case is for `ibuffer-saved-filter-groups' so completion
doesn't matter at all there.
>> 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))?
Uh. That would have been too easy. :-)
> 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.
-Ivan