Usually this function is called when the next input event arrives
after displaying an echo-area message. The function is expected to
clear the message displayed by its counterpart function specified by
-@code{set-message-function}.
+@code{set-message-function}, but doesn't have to. If the function
+wants the echo area to remain uncleared, it should return the symbol
+@code{dont-clear-message}; any other value will result in the echo
+area being cleared.
The default value is the function that clears the message displayed in
an active minibuffer.
\f
* Lisp Changes in Emacs 29.1
++++
+** The return value of 'clear-message-function' is not ignored anymore.
+If the function returns 'dont-clear-message', then the message is not
+cleared, with the assumption that the function cleared it itself.
+
+++
** The local variable section now supports defining fallback modes.
This was previously only available when using a property line (i.e.,
(setq minibuffer-message-timer nil))
(when (overlayp minibuffer-message-overlay)
(delete-overlay minibuffer-message-overlay)
- (setq minibuffer-message-overlay nil))))
+ (setq minibuffer-message-overlay nil)))
+
+ ;; Return nil telling the caller that the message
+ ;; should be also handled by the caller.
+ nil)
(setq clear-message-function 'clear-minibuffer-message)
void
clear_message (bool current_p, bool last_displayed_p)
{
+ Lisp_Object preserve = Qnil;
+
if (current_p)
{
- echo_area_buffer[0] = Qnil;
- message_cleared_p = true;
-
if (FUNCTIONP (Vclear_message_function))
{
specpdl_ref count = SPECPDL_INDEX ();
specbind (Qinhibit_quit, Qt);
- safe_call (1, Vclear_message_function);
+ preserve = safe_call (1, Vclear_message_function);
unbind_to (count, Qnil);
}
+
+ if (!EQ (preserve, Qdont_clear_message))
+ {
+ echo_area_buffer[0] = Qnil;
+ message_cleared_p = true;
+ }
}
if (last_displayed_p)
(which controls how error messages are displayed). */);
Vset_message_function = Qnil;
+ DEFSYM (Qdont_clear_message, "dont-clear-message");
DEFVAR_LISP ("clear-message-function", Vclear_message_function,
doc: /* If non-nil, function to clear echo-area messages.
Usually this function is called when the next input event arrives.
-The function is called without arguments. It is expected to clear the
-message displayed by its counterpart function specified by
-`set-message-function'. */);
+It is expected to clear the message displayed by its counterpart
+function specified by `set-message-function'.
+
+The function is called without arguments.
+
+If this function returns a value that isn't `dont-clear-message', the
+message is cleared from the echo area as usual. If this function
+returns `dont-clear-message', this means that the message was already
+handled, and the original message text will not be cleared from the
+echo area. */);
Vclear_message_function = Qnil;
DEFVAR_LISP ("redisplay--all-windows-cause", Vredisplay__all_windows_cause,