GNU bug report logs - #11295
24.0.95; New ibuffer filter derived-mode

Previous Next

Package: emacs;

Reported by: Ivan Andrus <darthandrus <at> gmail.com>

Date: Sat, 21 Apr 2012 11:13:01 UTC

Severity: wishlist

Found in version 24.0.95

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 11295 in the body.
You can then email your comments to 11295 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#11295; Package emacs. (Sat, 21 Apr 2012 11:13:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ivan Andrus <darthandrus <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 21 Apr 2012 11:13:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ivan Andrus <darthandrus <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.0.95; New ibuffer filter derived-mode
Date: Sat, 21 Apr 2012 13:11:35 +0200
I have often wished to be able to use derived-mode instead of mode when
filtering in ibuffer.  This allows, for example, grouping all make files
without specifying each variant make file mode individually.  I finally
looked into adding this and it's very easy.

I have attached one possible implemention below.  I feel it's definitely
a trivial addition (I don't have papers on file with the FSF) since it
consists mostly of copy/paste from `derived-mode-p' and the `mode'
ibuffer-filter.  If, however, you disagree that it's not trivial, please
reimplement as needed.  You can also contact me about papers, though it
seems like a lot of work for such a small addition.


  (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)))
                                    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)))


In GNU Emacs 24.0.95.1 (i386-apple-darwin10.8.0, NS apple-appkit-1038.36)
of 2012-04-07 on oroszlan.local




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11295; Package emacs. (Sat, 21 Apr 2012 14:26:02 GMT) Full text and rfc822 format available.

Message #8 received at 11295 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Ivan Andrus <darthandrus <at> gmail.com>
Cc: 11295 <at> debbugs.gnu.org
Subject: Re: bug#11295: 24.0.95; New ibuffer filter derived-mode
Date: Sat, 21 Apr 2012 10:24:54 -0400
>   (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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11295; Package emacs. (Sat, 21 Apr 2012 15:26:01 GMT) Full text and rfc822 format available.

Message #11 received at 11295 <at> debbugs.gnu.org (full text, mbox):

From: Ivan Andrus <darthandrus <at> gmail.com>
To: 11295 <at> debbugs.gnu.org
Subject: Re: 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



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11295; Package emacs. (Sat, 21 Apr 2012 19:46:01 GMT) Full text and rfc822 format available.

Message #14 received at 11295 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Ivan Andrus <darthandrus <at> gmail.com>
Cc: 11295 <at> debbugs.gnu.org
Subject: Re: bug#11295: 24.0.95; New ibuffer filter derived-mode
Date: Sat, 21 Apr 2012 15:44:41 -0400
>> 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,


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11295; Package emacs. (Mon, 23 Apr 2012 18:53:02 GMT) Full text and rfc822 format available.

Message #17 received at 11295 <at> debbugs.gnu.org (full text, mbox):

From: Ivan Andrus <darthandrus <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 11295 <at> debbugs.gnu.org
Subject: Re: bug#11295: 24.0.95; New ibuffer filter derived-mode
Date: Mon, 23 Apr 2012 20:51:21 +0200
[Message part 1 (text/plain, inline)]
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 <at> gnu.org for some changes in expand-region.el.

-Ivan

[ibuffer.patch (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11295; Package emacs. (Tue, 24 Apr 2012 03:48:01 GMT) Full text and rfc822 format available.

Message #20 received at 11295 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Ivan Andrus <darthandrus <at> gmail.com>
Cc: 11295 <at> debbugs.gnu.org
Subject: Re: bug#11295: 24.0.95; New ibuffer filter derived-mode
Date: Mon, 23 Apr 2012 23:46:21 -0400
> Attached is an updated patch.

Thank you, installed.

> 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.

`/ m' and `/ M' do the same, with `/ M' being the one with better
completion, so I moved the `/ M' binding to `/ m' and bound yours to `/ M'.

> FWIW, I contacted assign <at> gnu.org for some changes in expand-region.el.

Thank you very much,


        Stefan





bug closed, send any further explanations to 11295 <at> debbugs.gnu.org and Ivan Andrus <darthandrus <at> gmail.com> Request was from Stefan Monnier <monnier <at> iro.umontreal.ca> to control <at> debbugs.gnu.org. (Tue, 24 Apr 2012 03:48:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 22 May 2012 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 90 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.