unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#73047: 30.0.90; feature request - add recency column to ibuffer
@ 2024-09-05 15:28 Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-09-05 16:36 ` JD Smith
  2024-12-28 12:27 ` bug#73047: 31; [PATCH] " Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 2 replies; 5+ messages in thread
From: Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-09-05 15:28 UTC (permalink / raw)
  To: 73047

Dear Emacs maintainers,

I want to propose the addition of an optional recency column to Ibuffer,
which shows the last buffer display time. Sorting by recency is already
supported by Ibuffer (ibuffer-do-sort-by-recency). I use the following
code in my configuration:

(defvar-keymap ibuffer-recency-header-map
  "<mouse-1>" #'ibuffer-do-sort-by-recency)
  
(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)))
      (progn
        (require 'marginalia)
        (marginalia--time (buffer-local-value 'buffer-display-time buffer)))
    "never"))

The time string is formatted in a human readable form, relative to to
the current time, e.g., "2 mins ago", "30 secs ago" or "never". I use
the function from the Marginalia package from GNU ELPA for formatting
right now. As far as I know Emacs does not yet provide a relative time
formatting function? Maybe there is interest in adding marginalia--time
to Emacs, e.g., with the name format-time-relative? As far as I know,
multiple packages define a similar formatting function, such that we
could potentially get some code reuse. The function could be ported
back via Compat to make it available to ELPA packages.

Thank you!





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#73047: 30.0.90; feature request - add recency column to ibuffer
  2024-09-05 15:28 bug#73047: 30.0.90; feature request - add recency column to ibuffer Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-09-05 16:36 ` JD Smith
  2024-09-05 17:00   ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-12-28 12:27 ` bug#73047: 31; [PATCH] " Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 1 reply; 5+ messages in thread
From: JD Smith @ 2024-09-05 16:36 UTC (permalink / raw)
  To: Daniel Mendler; +Cc: 73047

[-- Attachment #1: Type: text/plain, Size: 463 bytes --]



> On Sep 5, 2024, at 11:28 AM, Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors <bug-gnu-emacs@gnu.org> wrote:
> 
> As far as I know, multiple packages define a similar formatting function, such that we
> could potentially get some code reuse. 

Definitely agree.  See bug#71572 <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71572#72>, which includes such a formatting function, heavily discussed, but not yet merged.

[-- Attachment #2: Type: text/html, Size: 853 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#73047: 30.0.90; feature request - add recency column to ibuffer
  2024-09-05 16:36 ` JD Smith
@ 2024-09-05 17:00   ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-09-05 17:00 UTC (permalink / raw)
  To: JD Smith; +Cc: 73047

JD Smith <jdtsmith@gmail.com> writes:

>> On Sep 5, 2024, at 11:28 AM, Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors <bug-gnu-emacs@gnu.org> wrote:
>> 
>> As far as I know, multiple packages define a similar formatting function, such that we
>> could potentially get some code reuse. 
>
> Definitely agree.  See bug#71572 <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71572#72>, which includes such a formatting function, heavily discussed, but not yet merged.

That's great! Thank you for working on this function.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#73047: 31; [PATCH] - add recency column to ibuffer
  2024-09-05 15:28 bug#73047: 30.0.90; feature request - add recency column to ibuffer Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-09-05 16:36 ` JD Smith
@ 2024-12-28 12:27 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-12-28 12:50   ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 1 reply; 5+ messages in thread
From: Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-28 12:27 UTC (permalink / raw)
  To: 73047; +Cc: JD Smith

[-- Attachment #1: Type: text/plain, Size: 145 bytes --]

I've attached a patch to this mail which adds a recency column to
Ibuffer. It uses the `seconds-to-string' function with the READABLE
argument.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ibuffer-Define-recency-column.patch --]
[-- Type: text/x-diff, Size: 1719 bytes --]

From 33b5a0880cf7fe4e002d1c9f73bc20e79d77317e Mon Sep 17 00:00:00 2001
From: Daniel Mendler <mail@daniel-mendler.de>
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
   "<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,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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#73047: 31; [PATCH] - add recency column to ibuffer
  2024-12-28 12:27 ` bug#73047: 31; [PATCH] " Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-12-28 12:50   ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-28 12:50 UTC (permalink / raw)
  To: 73047; +Cc: JD Smith

[-- Attachment #1: Type: text/plain, Size: 325 bytes --]

Daniel Mendler <mail@daniel-mendler.de> writes:

> I've attached a patch to this mail which adds a recency column to
> Ibuffer. It uses the `seconds-to-string' function with the READABLE
> argument.

Please disregard the earlier patch, which was a wrong version.  I've
attached a better patch to this mail.  Thanks.

Daniel


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ibuffer-Define-recency-column.patch --]
[-- Type: text/x-diff, Size: 1595 bytes --]

From aed32b8dbf8fa0f17acc76ea2e444436bc347e12 Mon Sep 17 00:00:00 2001
From: Daniel Mendler <mail@daniel-mendler.de>
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 | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el
index 405fb98d4d4..4f849bed27b 100644
--- a/lisp/ibuffer.el
+++ b/lisp/ibuffer.el
@@ -775,6 +775,9 @@ ibuffer-size-header-map
 (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 @@ 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 time)) t t))
+    "never"))
+
 (define-ibuffer-column mode
   (:inline t
    :header-mouse-map ibuffer-mode-header-map
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-12-28 12:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-05 15:28 bug#73047: 30.0.90; feature request - add recency column to ibuffer Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-05 16:36 ` JD Smith
2024-09-05 17:00   ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-28 12:27 ` bug#73047: 31; [PATCH] " Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-28 12:50   ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).