summaryrefslogtreecommitdiff
path: root/lisp/ibuffer.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2021-02-04 12:59:16 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2021-02-04 12:59:16 +0100
commitd3cb07d784a4c4029f0a50ba003ebf4b93dd59c3 (patch)
treec4e31933c1e56d4b8e168756d808feca6ecbfd7f /lisp/ibuffer.el
parent3b27f2e46494cbcb5a2c81bd68617ecdf3bc4ad9 (diff)
downloademacs-d3cb07d784a4c4029f0a50ba003ebf4b93dd59c3.tar.gz
emacs-d3cb07d784a4c4029f0a50ba003ebf4b93dd59c3.tar.bz2
emacs-d3cb07d784a4c4029f0a50ba003ebf4b93dd59c3.zip
Make the recency sorting stable when we have inverted sorting
* lisp/ibuffer.el (recency): Remove. (recency): New macro function so that sorting by recency is stable when inverted sorting is switched on (bug#30129).
Diffstat (limited to 'lisp/ibuffer.el')
-rw-r--r--lisp/ibuffer.el18
1 files changed, 7 insertions, 11 deletions
diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el
index 84c53b16acf..c91a70b3a1c 100644
--- a/lisp/ibuffer.el
+++ b/lisp/ibuffer.el
@@ -219,7 +219,6 @@ view of the buffers."
(const :tag "File name" :value filename/process)
(const :tag "Major mode" :value major-mode)))
(defvar ibuffer-sorting-mode nil)
-(defvar ibuffer-last-sorting-mode nil)
(defcustom ibuffer-default-sorting-reversep nil
"If non-nil, reverse the default sorting order."
@@ -2129,16 +2128,13 @@ the value of point at the beginning of the line for that buffer."
(and ibuffer-buf
(not (eq ibuffer-buf buf))))))
-;; This function is a special case; it's not defined by
-;; `define-ibuffer-sorter'.
-(defun ibuffer-do-sort-by-recency ()
- "Sort the buffers by last view time."
- (interactive)
- (setq ibuffer-sorting-mode 'recency)
- (when (eq ibuffer-last-sorting-mode 'recency)
- (setq ibuffer-sorting-reversep (not ibuffer-sorting-reversep)))
- (ibuffer-update nil t)
- (setq ibuffer-last-sorting-mode 'recency))
+(define-ibuffer-sorter recency
+ "Sort the buffers by how recently they've been used."
+ (:description "recency")
+ (time-less-p (with-current-buffer (car b)
+ (or buffer-display-time 0))
+ (with-current-buffer (car a)
+ (or buffer-display-time 0))))
(defun ibuffer-update-format ()
(when (null ibuffer-current-format)