ibuffer: Add the "Recency" column

Define a column which shows how many seconds ago the respective
buffer has been displayed.  The time is formatted with the
`seconds-to-string' function, with the new arguments READABLE=t
and ABBREV=t.
* lisp/ibuffer.el (ibuffer-recency-header-map): New keymap.
(define-ibuffer-column recency): New column.
* etc/NEWS: Mention new `recency' column.  (Bug#73047)
This commit is contained in:
Daniel Mendler 2024-12-28 13:21:46 +01:00 committed by Eli Zaretskii
parent 3d960c16c6
commit 266e1c34d8
2 changed files with 15 additions and 0 deletions

View file

@ -332,6 +332,11 @@ modal editing packages.
* Changes in Specialized Modes and Packages in Emacs 31.1
** Ibuffer
*** New 'recency' column.
The variable 'ibuffer-formats' configures the Ibuffer formats. Add
'recency' to a format to display the column.
** Smerge
*** New command 'smerge-extend' extends a conflict over surrounding lines.

View file

@ -775,6 +775,9 @@ directory, like `default-directory'."
(defvar-keymap ibuffer-mode-header-map
"<mouse-1>" #'ibuffer-do-sort-by-major-mode)
(defvar-keymap ibuffer-recency-header-map
"<mouse-1>" #'ibuffer-do-sort-by-recency)
(defvar-keymap ibuffer-mode-filter-group-map
"<mouse-1>" #'ibuffer-mouse-toggle-mark
"<mouse-2>" #'ibuffer-mouse-toggle-filter-group
@ -1721,6 +1724,13 @@ If point is on a group name, this function operates on that group."
(format "%.0f" total))))
(format "%s" (buffer-size)))
(define-ibuffer-column recency
(:inline t :summarizer ignore :header-mouse-map ibuffer-recency-header-map)
(if-let* ((time (buffer-local-value 'buffer-display-time buffer)))
(format "%s ago" (seconds-to-string
(float-time (time-since time)) t t))
"never"))
(define-ibuffer-column mode
(:inline t
:header-mouse-map ibuffer-mode-header-map