Subject: bug#79253: Add timestamps to *Messages*

From: Eli Zaretskii <[email-masked]>
Date: Mon, 18 Aug 2025 14:39:23 +0300

> Cc: [email-masked]
> Date: Mon, 18 Aug 2025 08:49:55 +0200
> From:  "R. Diez" via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> > Ordinary Emacs editing is sequential and only the order matters.
> > For people like me, whi do that, timestamps would be unhelpful clutter.
> > So if we implement timestamps, there should be an easy way to turn them off.
> 
> When I switch to a *Compile-Log* buffer, I get an extra menu at the top called "Compile", with options like "Next Error" and "Stop Compilation".
> 
> Wouldn't it be cool if the *Messages* buffer also displayed a new menu with options like "Show Timestamps", "Show Time Deltas" and "Clear Buffer"?

See my earlier reply: the *Messages* buffer is put under a special
major mode, so that mode could define menus that are useful in that
buffer.  Patches welcome.

> But I am now more inclined to just offer a hook to capture the text lines sent to the *Messages* buffer. This way, you have complete freedom: you can send the text lines to syslog and/or implement your own *Enhanced Messages* buffer with all those features. I'm sure somebody would then write an Emacs package with such functionality. After the hook, the only other thing probably missing is to change all internal callers so that they write whole lines in a go.

I don't think a hook is necessary.  You could write a special minor
mode, whereby a timer would periodically copy the contents of the
*Messages* buffer to a file or a system log or whatever.

(Having hooks for inserting text into *Messages* is hard technically
because we deliberately use low-level functions to do that, to avoid
any such hooks, because hooks could be unsafe to run, and having such
a hook signal an error while storing messages into *Messages* might
render Emacs unusable.)