39.4.3 Logging Messages in *Messages*
Almost all the messages displayed in the echo area are also recorded in the *Messages*
buffer so that the user can refer back to them. This includes all the messages that are output with message
. By default, this buffer is read-only and uses the major mode messages-buffer-mode
. Nothing prevents the user from killing the *Messages*
buffer, but the next display of a message recreates it. Any Lisp code that needs to access the *Messages*
buffer directly and wants to ensure that it exists should use the function messages-buffer
.
function
messages-bufferβ
This function returns the *Messages*
buffer. If it does not exist, it creates it, and switches it to messages-buffer-mode
.
user option
message-log-maxβ
This variable specifies how many lines to keep in the *Messages*
buffer. The value t
means there is no limit on how many lines to keep. The value nil
disables message logging entirely. Hereβs how to display a message and prevent it from being logged:
(let (message-log-max)
(message β¦))
To make *Messages*
more convenient for the user, the logging facility combines successive identical messages. It also combines successive related messages for the sake of two cases: question followed by answer, and a series of progress messages.
A question followed by an answer has two messages like the ones produced by y-or-n-p
: the first is βquestion
β, and the second is βquestion...answer
β. The first message conveys no additional information beyond whatβs in the second, so logging the second message discards the first from the log.
A series of progress messages has successive messages like those produced by make-progress-reporter
. They have the form βbase...how-far
β, where base
is the same each time, while how-far
varies. Logging each message in the series discards the previous one, provided they are consecutive.
The functions make-progress-reporter
and y-or-n-p
donβt have to do anything special to activate the message log combination feature. It operates whenever two consecutive messages are logged that share a common prefix ending in β...
β.