# HG changeset patch # User Colin Walters # Date 1013936244 0 # Node ID 3fce95e542b12a8be4ae6df2a461b8a013911cde # Parent 5043145dbf593b1c9ae5df46e85e0b1dea40e203 (ibuffer-toggle-sorting-mode): Make it work. Patch from John Paul Wallington . diff -r 5043145dbf59 -r 3fce95e542b1 lisp/ibuf-ext.el --- a/lisp/ibuf-ext.el Sun Feb 17 08:57:09 2002 +0000 +++ b/lisp/ibuf-ext.el Sun Feb 17 08:57:24 2002 +0000 @@ -654,23 +654,20 @@ ;;;###autoload (defun ibuffer-toggle-sorting-mode () "Toggle the current sorting mode. -Possible sorting modes are: +Default sorting modes are: Recency - the last time the buffer was viewed Name - the name of the buffer Major Mode - the name of the major mode of the buffer Size - the size of the buffer" (interactive) - (let* ((keys (mapcar #'car ibuffer-sorting-functions-alist)) - (entry (memq ibuffer-sorting-mode keys)) - (next (or (cadr entry) (car keys))) - (nextentry (assq next ibuffer-sorting-functions-alist))) - (if (and entry nextentry) - (progn - (setq ibuffer-sorting-mode next) - (message "Sorting by %s" (cadr nextentry))) - (progn - (setq ibuffer-sorting-mode 'recency) - (message "Sorting by last view time")))) + (let ((modes (mapcar 'car ibuffer-sorting-functions-alist))) + (add-to-list 'modes 'recency) + (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))) (ibuffer-redisplay t)) ;;;###autoload