]> git.eshelyaron.com Git - emacs.git/commitdiff
(ibuffer-list-buffer-modes): New.
authorColin Walters <walters@gnu.org>
Tue, 6 Aug 2002 06:04:44 +0000 (06:04 +0000)
committerColin Walters <walters@gnu.org>
Tue, 6 Aug 2002 06:04:44 +0000 (06:04 +0000)
(ibuffer-filter-by-used-mode): New.

lisp/ibuf-ext.el

index ff4e8b76e81a1042e597fe8de0b4010bab365884..6c279d2642f49db4f676fc57a6cf937cef7c01f7 100644 (file)
@@ -922,6 +922,26 @@ of replacing the current filters."
         (error "Ibuffer: bad qualifier %s" qualifier))
        (concat " [" (cadr type) ": " (format "%s]" (cdr qualifier)))))))
   
+
+(defun ibuffer-list-buffer-modes ()
+  "Create an alist of buffer modes currently in use.
+The list returned will be of the form ("MODE-NAME" . MODE-SYMBOL)."
+  (let ((bufs (buffer-list))
+       (modes)
+       (this-mode))
+    (while bufs
+      (setq this-mode 
+           (with-current-buffer 
+               (car bufs)
+             major-mode)
+           bufs (cdr bufs))
+      (add-to-list 
+       'modes
+       `(,(symbol-name this-mode) . 
+        ,this-mode)))
+    modes)) 
+
+
 ;;; Extra operation definitions
 
 ;;;###autoload (autoload 'ibuffer-filter-by-mode "ibuf-ext.el")
@@ -942,6 +962,25 @@ of replacing the current filters."
                         "")))))
   (eq qualifier (with-current-buffer buf major-mode)))
 
+;;;###autoload (autoload 'ibuffer-filter-by-used-mode "ibuf-ext.el")
+(define-ibuffer-filter used-mode 
+  "Toggle current view to buffers with major mode QUALIFIER.
+Called interactively, this function allows selection of modes
+currently used by buffers."
+  (:description "major mode in use"
+               :reader
+               (intern 
+                (completing-read "Filter by major mode: " 
+                                 (ibuffer-list-buffer-modes)
+                                 nil
+                                 t
+                                 (let ((buf (ibuffer-current-buffer)))
+                                   (if (and buf (buffer-live-p buf))
+                                       (with-current-buffer buf
+                                         (symbol-name major-mode))
+                                     "")))))
+  (eq qualifier (with-current-buffer buf major-mode)))
+
 ;;;###autoload (autoload 'ibuffer-filter-by-name "ibuf-ext.el")
 (define-ibuffer-filter name 
   "Toggle current view to buffers with name matching QUALIFIER."