[Top][All Lists]

[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 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"
                   (completing-read "Filter by major mode: " obarray
                                    #'(lambda (e)
                                        (string-match "-mode$"
                                                      (symbol-name e)))
                                    (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 (i386-apple-darwin10.8.0, NS apple-appkit-1038.36)
of 2012-04-07 on oroszlan.local

reply via email to

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