>From 79e43be851ffd51e7353900207c254afd6123e84 Mon Sep 17 00:00:00 2001 From: dickmao Date: Tue, 25 Oct 2022 16:47:09 -0400 Subject: [PATCH] Respect inhibit-message That means not blithely clearing the echo area. * doc/lispref/display.texi (Displaying Messages): Revert 164a7eb. * lisp/minibuffer.el (clear-minibuffer-message): Revert 164a7eb. * src/xdisp.c (message3): Remove errant clear_message() from 2004. (clear_message): Revert 164a7eb. (syms_of_xdisp): Revert 164a7eb. * test/src/xdisp-tests.el (xdisp-tests--respect-inhibit-message): Test it. --- doc/lispref/display.texi | 5 +---- lisp/minibuffer.el | 6 +----- src/xdisp.c | 28 +++++++--------------------- test/src/xdisp-tests.el | 9 +++++++++ 4 files changed, 18 insertions(+), 30 deletions(-) diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 15cd5518d91..b7e39679bcb 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -337,10 +337,7 @@ Displaying Messages 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}, 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. +@code{set-message-function}. The default value is the function that clears the message displayed in an active minibuffer. diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index a9f72d600de..98b68443c38 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -861,11 +861,7 @@ clear-minibuffer-message (setq minibuffer-message-timer nil)) (when (overlayp minibuffer-message-overlay) (delete-overlay minibuffer-message-overlay) - (setq minibuffer-message-overlay nil))) - - ;; Return nil telling the caller that the message - ;; should be also handled by the caller. - nil) + (setq minibuffer-message-overlay nil)))) (setq clear-message-function 'clear-minibuffer-message) diff --git a/src/xdisp.c b/src/xdisp.c index 1f7ac269e4e..24e129f13f8 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -11948,7 +11948,6 @@ message_log_check_duplicate (ptrdiff_t prev_bol_byte, ptrdiff_t this_bol_byte) void message3 (Lisp_Object m) { - clear_message (true, true); cancel_echoing (); /* First flush out any partial line written with print. */ @@ -12966,23 +12965,18 @@ set_message_1 (void *a1, Lisp_Object string) 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); - preserve = safe_call (1, Vclear_message_function); + 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) @@ -37171,20 +37165,12 @@ syms_of_xdisp (void) (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. -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. */); +The function is called without arguments. It is expected to clear the +message displayed by its counterpart function specified by +`set-message-function'. */); Vclear_message_function = Qnil; DEFVAR_LISP ("redisplay--all-windows-cause", Vredisplay__all_windows_cause, diff --git a/test/src/xdisp-tests.el b/test/src/xdisp-tests.el index 6ff64d0431a..9e3ad3bd6eb 100644 --- a/test/src/xdisp-tests.el +++ b/test/src/xdisp-tests.el @@ -179,4 +179,13 @@ test-messages-buffer-name (buffer-string))) "foo\n"))) +(ert-deftest xdisp-tests--respect-inhibit-message () + "It's borderline criminal that inhibit-message still clears echo area." + (skip-unless (not noninteractive)) + (let ((dont "dont clear me!")) + (message dont) + (let ((inhibit-message t)) + (message "nice try") + (should (equal (current-message) dont))))) + ;;; xdisp-tests.el ends here -- 2.36.1