Commits

jpw  committed 23afbc8

* ibuffer.el (ibuffer-formats): change defaults, in particular
use major-mode column.
(ibuffer-default-sorting-mode): add mode-name choice.
(ibuffer-toggle-sorting-modes): new customizable variable.
(ibuffer-mode-map): add binding for ibuffer-do-sort-by-mode-name.
(ibuffer-mode-sort-menu): add entry for ibuffer-do-sort-by-mode-name.
(toplevel): define-ibuffer-column major-mode.
* ibuf-ext.el (ibuffer-toggle-sorting-mode): use
ibuffer-toggle-sorting-modes. More verbose message.
(toplevel): define-ibuffer-sorter mode-name.

  • Participants
  • Parent commits c98e2f4

Comments (0)

Files changed (3)

+2002-02-26  John Paul Wallington  <jpw@xemacs.org>
+
+	* ibuffer.el (ibuffer-formats): change defaults, in particular
+	use major-mode column.
+	(ibuffer-default-sorting-mode): add mode-name choice.
+	(ibuffer-toggle-sorting-modes): new customizable variable.
+	(ibuffer-mode-map): add binding for ibuffer-do-sort-by-mode-name.
+	(ibuffer-mode-sort-menu): add entry for ibuffer-do-sort-by-mode-name.
+	(toplevel): define-ibuffer-column major-mode.
+	* ibuf-ext.el (ibuffer-toggle-sorting-mode): use 
+	ibuffer-toggle-sorting-modes.  More verbose message.
+	(toplevel): define-ibuffer-sorter mode-name.
+	
 2002-02-25  John Paul Wallington  <jpw@xemacs.org>
 
 	* ibuffer.el (ibuffer-shrink-to-fit): use ibuffer-window-list.
   "Toggle the current sorting mode.
 Default sorting modes are:
  Recency - the last time the buffer was viewed
- Name - the `buffer-name' of the buffer
+ Alphabetic - the `buffer-name' of the buffer
  Major Mode - the `major-mode' of the buffer
+ Mode Name - the `mode-name' of the buffer
  Size - the `buffer-size' of the buffer"
   (interactive)
-  (let ((modes (mapcar 'car ibuffer-sorting-functions-alist)))
-    (add-to-list 'modes 'recency)
+  (let ((modes (if (eq ibuffer-toggle-sorting-modes 'all)
+		   (cons 'recency (mapcar 'car ibuffer-sorting-functions-alist))
+		 (if (listp ibuffer-toggle-sorting-modes)
+		     ibuffer-toggle-sorting-modes
+		   '(alphabetic major-mode mode-name buffer-size)))))
     (setq modes (sort modes 'string-lessp))
     (let ((next (or (find-if 
 		     (lambda (x) (string-lessp ibuffer-sorting-mode x)) modes)
 		    (car modes))))
       (setq ibuffer-sorting-mode next)
-      (message "Sorting by %s" next)))
+      (message "Sorting by %s (%s)" 
+	       (if (eq next 'recency)
+		   "last view time"
+		 (cadr (assq next ibuffer-sorting-functions-alist)))
+	       next)))
   (ibuffer-redisplay t))
 
 ;;;###autoload
 				  (car b)
 				major-mode)))))
 
+(define-ibuffer-sorter mode-name
+  "Sort the buffer by mode names.
+Ordering is lexicographic."
+  (:description "major mode name")
+  (string-lessp (downcase
+		 (with-current-buffer
+		     (car a)
+		   mode-name))
+		(downcase
+		 (with-current-buffer
+		     (car b)
+		   mode-name))))
+
 (define-ibuffer-sorter alphabetic
   "Sort the buffers by their names.
 Ordering is lexicographic."
 
 (define-ibuffer-sorter size
  "Sort the buffers by their size."
-  (:description "size")
+  (:description "buffer size")
   (< (with-current-buffer (car a)
        (buffer-size))
      (with-current-buffer (car b)
 (defcustom ibuffer-formats '((mark modified read-only " " (name 16 16 :left :elide)
 				   " " (size 6 -1 :right)
 				   " " (mode 16 16 :center :elide) " " filename)
-			     (mark " " (name 16 -1) " " filename))
+			     (mark "  " (name 18 -1 :left :elide) "  " (major-mode 20 -1 :left :elide) "  " filename))
   "A list of ways to display buffer lines.
 
 With Ibuffer, you are not limited to displaying just certain
   :type '(choice (const :tag "Last view time" :value recency)
 		 (const :tag "Lexicographic" :value alphabetic)
 		 (const :tag "Buffer size" :value size)
-		 (const :tag "Major mode" :value major-mode))
+		 (const :tag "Major mode" :value major-mode)
+		 (const :tag "Mode name" :value mode-name))
   :group 'ibuffer)
 (defvar ibuffer-sorting-mode nil)
 
+(defcustom ibuffer-toggle-sorting-modes '(alphabetic major-mode mode-name recency size)
+  "List of sorters that `ibuffer-toggle-sorting-mode' toggles between."
+  :type '(choice (repeat :tag "Edit" (symbol :tag "Sorter"))
+		 (const :tag "Default" :value (alphabetic major-mode mode-name recency size))
+		 (const :tag "All" :value all))
+  :group 'ibuffer)
+
 (defcustom ibuffer-default-sorting-reversep nil
   "If non-nil, reverse the default sorting order."
   :type 'boolean
     (define-key map (kbd "s v") 'ibuffer-do-sort-by-recency)
     (define-key map (kbd "s s") 'ibuffer-do-sort-by-size)
     (define-key map (kbd "s m") 'ibuffer-do-sort-by-major-mode)
+    (define-key map (kbd "s M") 'ibuffer-do-sort-by-mode-name)
 
     (define-key map (kbd "/ m") 'ibuffer-filter-by-mode)
     (define-key map (kbd "/ n") 'ibuffer-filter-by-name)
       ["Sort by view time" ibuffer-do-sort-by-recency t]
       ["Sort lexicographically" ibuffer-do-sort-by-alphabetic t]
       ["Sort by buffer size" ibuffer-do-sort-by-size t]
-      ["Sort by major mode" ibuffer-do-sort-by-major-mode t])))
+      ["Sort by major mode" ibuffer-do-sort-by-major-mode t]
+      ["Sort by mode name" ibuffer-do-sort-by-mode-name t])))
 
 (unless ibuffer-mode-immediate-menu
   (easy-menu-define
 			     :props
 			     ('mouse-face 'highlight
   			      'keymap ibuffer-mode-name-map
-			      'help-echo "button2: filter by mode"))
+			      'help-echo "button2: filter by mode-name"))
   (format "%s" mode-name))
 
+(define-ibuffer-column major-mode (:inline t
+			           :props
+				   ('mouse-face 'highlight
+				    'keymap ibuffer-mode-name-map
+				    'help-echo "button2: filter by major-mode"))
+  (format "%s" major-mode))
+
 (define-ibuffer-column process ()
   (let ((proc (get-buffer-process buffer)))
     (if proc