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

From: "R. Diez" <[email-masked]>
Date: Sun, 17 Aug 2025 20:04:04 +0200

> [...]
> This happens because in this case we call 'message' 3 times, with the
> following 3 strings:
> 
>    "previous-line"
>    ": "
>    "Beginning of buffer"

That looks like a wrong API design to me. The *Message* buffer is obviously line-oriented. If someone makes multiple calls to message_dolog() in order to create a single text line, then somebody else calling message_dolog() or 'message' between those calls will break that line.

I do not know anything about Emacs' internals, but I would imagine that inserting text in a buffer carries some overhead. Wouldn't it be more efficient anyway if the caller pieced together the complete line before calling message_dolog()?

> I would also like to see automatic scrolling,

Automatic scrolling works for me.

> along with two new key bindings, one for adding some sort of separator and another for clearing the buffer.

I have also missed a way to clear the *Messages* buffer, or to add a separator, in order to know if a text line came after the latest change I made in my code.

In fact, I have written a tool to automatically add a separator when a log pause is detected in the console:

https://github.com/rdiez/Tools/tree/master/LogPauseDetector

But it is hard to implement such things in Emacs, because there are no hooks for the 'message' function.

One thing that has always bothered me is that Emacs does not persist the *Messages* buffer. Because I am pretty bad at Lisp, sometimes my code fails under some weird circumstances. Or somebody else's code, like the recent trouble with Tramp's session timeouts. I then wanted to check whether I have gotten a particular message in the past, and what messages were around it, but the contents of *Messages* gets lost between reboots.

I thought of piping all *Messages* lines to syslog, but I couldn't find a hook to do that. If I could do it, I wouldn't need timestamps, because syslog would take care of that automatically. By the way, that would require whole-line additions too.