blob: 752a223c7ec402a4150728aa4e7ce8269c3574bf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
<h4 class="subsection">Logging Messages in *Messages*</h4> <p>Almost all the messages displayed in the echo area are also recorded in the <samp>*Messages*</samp> buffer so that the user can refer back to them. This includes all the messages that are output with <code>message</code>. By default, this buffer is read-only and uses the major mode <code>messages-buffer-mode</code>. Nothing prevents the user from killing the <samp>*Messages*</samp> buffer, but the next display of a message recreates it. Any Lisp code that needs to access the <samp>*Messages*</samp> buffer directly and wants to ensure that it exists should use the function <code>messages-buffer</code>. </p> <dl> <dt id="messages-buffer">Function: <strong>messages-buffer</strong>
</dt> <dd><p>This function returns the <samp>*Messages*</samp> buffer. If it does not exist, it creates it, and switches it to <code>messages-buffer-mode</code>. </p></dd>
</dl> <dl> <dt id="message-log-max">User Option: <strong>message-log-max</strong>
</dt> <dd>
<p>This variable specifies how many lines to keep in the <samp>*Messages*</samp> buffer. The value <code>t</code> means there is no limit on how many lines to keep. The value <code>nil</code> disables message logging entirely. Here’s how to display a message and prevent it from being logged: </p> <div class="example"> <pre class="example">(let (message-log-max)
(message …))
</pre>
</div> </dd>
</dl> <p>To make <samp>*Messages*</samp> 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. </p> <p>A question followed by an answer has two messages like the ones produced by <code>y-or-n-p</code>: the first is ‘<samp><var>question</var></samp>’, and the second is ‘<samp><var>question</var>...<var>answer</var></samp>’. The first message conveys no additional information beyond what’s in the second, so logging the second message discards the first from the log. </p> <p>A series of progress messages has successive messages like those produced by <code>make-progress-reporter</code>. They have the form ‘<samp><var>base</var>...<var>how-far</var></samp>’, where <var>base</var> is the same each time, while <var>how-far</var> varies. Logging each message in the series discards the previous one, provided they are consecutive. </p> <p>The functions <code>make-progress-reporter</code> and <code>y-or-n-p</code> 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 ‘<samp>...</samp>’. </p><div class="_attribution">
<p class="_attribution-p">
Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
<a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Logging-Messages.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Logging-Messages.html</a>
</p>
</div>
|