From 33b5a0880cf7fe4e002d1c9f73bc20e79d77317e Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Sat, 28 Dec 2024 13:21:46 +0100 Subject: [PATCH] ibuffer: Define 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. --- lisp/ibuffer.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el index 405fb98d4d4..10e26cba589 100644 --- a/lisp/ibuffer.el +++ b/lisp/ibuffer.el @@ -775,6 +775,9 @@ ibuffer-size-header-map (defvar-keymap ibuffer-mode-header-map "" #'ibuffer-do-sort-by-major-mode) +(defvar-keymap ibuffer-recency-header-map + "" #'ibuffer-do-sort-by-recency) + (defvar-keymap ibuffer-mode-filter-group-map "" #'ibuffer-mouse-toggle-mark "" #'ibuffer-mouse-toggle-filter-group @@ -1721,6 +1724,16 @@ size (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 + (buffer-local-value 'buffer-display-time buffer))) + t t)) + "never")) + (define-ibuffer-column mode (:inline t :header-mouse-map ibuffer-mode-header-map -- 2.45.2