[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master aa89c84: message uses minibuffer-message in the active minibuffer

From: Juri Linkov
Subject: master aa89c84: message uses minibuffer-message in the active minibuffer (bug#17272 bug#19064)
Date: Tue, 26 Nov 2019 18:43:57 -0500 (EST)

branch: master
commit aa89c84e00d8dc85100e6fedab7631c415e6364d
Author: Juri Linkov <address@hidden>
Commit: Juri Linkov <address@hidden>

    message uses minibuffer-message in the active minibuffer (bug#17272 
    * doc/lispref/display.texi (Displaying Messages): Explain the
    behavior of using minibuffer-message if the minibuffer is active.
    * src/editfns.c (Fmessage_in_echo_area): New function with body
    copied from Fmessage.
    (Fmessage): Call minibuffer-message in the active minibuffer,
    otherwise call Fmessage_in_echo_area.
    (message-in-echo-area): New variable.
    * lisp/isearch.el (isearch--momentary-message, isearch-message):
    * lisp/minibuffer.el (minibuffer-message, minibuffer-completion-help):
    Use 'message-in-echo-area' instead of 'message' where necessary.
    * lisp/autorevert.el (auto-revert-handler):
    * lisp/man.el (Man-bgproc-sentinel):
    * lisp/subr.el (do-after-load-evaluation):
    Revert recent changes that replaced 'message' with 'minibuffer-message'.
    This is not needed anymore since 'message' uses 'minibuffer-message'
    in the active minibuffer.
 doc/lispref/display.texi |  8 ++++---
 etc/NEWS                 |  4 ++++
 lisp/autorevert.el       |  3 +--
 lisp/isearch.el          |  4 ++--
 lisp/man.el              |  2 +-
 lisp/minibuffer.el       | 12 +++++------
 lisp/subr.el             |  2 +-
 src/editfns.c            | 56 ++++++++++++++++++++++++++++++++++++++++++++++++
 8 files changed, 76 insertions(+), 15 deletions(-)

diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index ddbae40..1f7cc93 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -276,11 +276,13 @@ followed by a newline.
 When @code{inhibit-message} is non-@code{nil}, no message will be displayed
 in the echo area, it will only be logged to @samp{*Messages*}.
+If the minibuffer is active, it uses the @code{minibuffer-message}
+function to display the message temporarily at the end of the
+minibuffer (@pxref{Minibuffer Misc}).
 If @var{format-string} is @code{nil} or the empty string,
 @code{message} clears the echo area; if the echo area has been
-expanded automatically, this brings it back to its normal size.  If
-the minibuffer is active, this brings the minibuffer contents back
-onto the screen immediately.
+expanded automatically, this brings it back to its normal size.
diff --git a/etc/NEWS b/etc/NEWS
index 662156d..eb32d70 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -755,6 +755,10 @@ the minibuffer.  If non-nil, point will move to the end of 
the prompt
 at the end of the active minibuffer.
+*** The function 'message' now displays the message at the end of the 
+when the minibuffer is active.
 *** 'y-or-n-p' now uses the minibuffer to read 'y' or 'n' answer.
 *** Some commands that previously used read-char-choice now read
diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index 079750a..9275513 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -815,8 +815,7 @@ This is an internal function used by Auto-Revert Mode."
     (when revert
       (when (and auto-revert-verbose
                  (not (eq revert 'fast)))
-        (with-current-buffer (window-buffer (old-selected-window))
-          (minibuffer-message "Reverting buffer `%s'." (buffer-name))))
+        (message "Reverting buffer `%s'." (buffer-name)))
       ;; If point (or a window point) is at the end of the buffer, we
       ;; want to keep it at the end after reverting.  This allows one
       ;; to tail a file.
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 4f33427..7c22e6a 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -2011,7 +2011,7 @@ Turning on character-folding turns off regexp mode.")
 (defun isearch--momentary-message (string)
   "Print STRING at the end of the isearch prompt for 1 second."
   (let ((message-log-max nil))
-    (message "%s%s%s"
+    (message-in-echo-area "%s%s%s"
              (isearch-message-prefix nil isearch-nonincremental)
              (apply #'propertize (format " [%s]" string)
@@ -3168,7 +3168,7 @@ If there is no completion possible, say so and continue 
             (isearch-message-prefix ellipsis isearch-nonincremental)
             (isearch-message-suffix c-q-hack)))
-    (if c-q-hack m (let ((message-log-max nil)) (message "%s" m)))))
+    (if c-q-hack m (let ((message-log-max nil)) (message-in-echo-area "%s" 
 (defun isearch--describe-regexp-mode (regexp-function &optional space-before)
   "Make a string for describing REGEXP-FUNCTION.
diff --git a/lisp/man.el b/lisp/man.el
index ce01fdc..beec2e6 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -1474,7 +1474,7 @@ manpage command."
           (kill-buffer Man-buffer)))
       (when message
-        (minibuffer-message "%s" message)))))
+        (message "%s" message)))))
 (defun Man-page-from-arguments (args)
   ;; Skip arguments and only print the page name.
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index b9e5d5a..a7bdde4 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -712,16 +712,16 @@ If ARGS are provided, then pass MESSAGE through 
         (if args
             (apply #'message message args)
-          (message "%s" message))
+          (message-in-echo-area "%s" message))
         (prog1 (sit-for (or minibuffer-message-timeout 1000000))
-          (message nil)))
+          (message-in-echo-area nil)))
     ;; Record message in the *Messages* buffer
     (let ((inhibit-message t))
       (if args
           (apply #'message message args)
-        (message "%s" message)))
+        (message-in-echo-area "%s" message)))
     ;; Clear out any old echo-area message to make way for our new thing.
-    (message nil)
+    (message-in-echo-area nil)
     (setq message (if (and (null args)
                            (string-match-p "\\` *\\[.+\\]\\'" message))
                       ;; Make sure we can put-text-property.
@@ -1840,7 +1840,7 @@ variables.")
 (defun minibuffer-completion-help (&optional start end)
   "Display a list of possible completions of the current minibuffer contents."
-  (message "Making completion list...")
+  (message-in-echo-area "Making completion list...")
   (let* ((start (or start (minibuffer-prompt-end)))
          (end (or end (point-max)))
          (string (buffer-substring start end))
@@ -1851,7 +1851,7 @@ variables.")
                        (- (point) start)
-    (message nil)
+    (message-in-echo-area nil)
     (if (or (null completions)
             (and (not (consp (cdr completions)))
                  (equal (car completions) string)))
diff --git a/lisp/subr.el b/lisp/subr.el
index 01f4f53..7e8c4fc 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4607,7 +4607,7 @@ This function is called directly from the C code."
                                       (string-match "\\.elc?\\>" file))
           (msg (format "Package %s is deprecated" package))
-          (fun (lambda (msg) (minibuffer-message "%s" msg))))
+          (fun (lambda (msg) (message "%s" msg))))
       ;; Cribbed from cl--compiling-file.
       (when (or (not (fboundp 'byte-compile-warning-enabled-p))
                 (byte-compile-warning-enabled-p 'obsolete package))
diff --git a/src/editfns.c b/src/editfns.c
index 8fc866d..72a9cdb 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -2875,9 +2875,59 @@ If the first argument is nil or the empty string, the 
function clears
 any existing message; this lets the minibuffer contents show.  See
 also `current-message'.
+When the variable `message-in-echo-area' is non-nil, use the function
+`message-in-echo-area' to display the message in the echo area.
+Otherwise, when the minibuffer is active, use `minibuffer-message'
+to temporarily display the message at the end of the minibuffer.
 usage: (message FORMAT-STRING &rest ARGS)  */)
   (ptrdiff_t nargs, Lisp_Object *args)
+  if (NILP (Vmessage_in_echo_area)
+      && !inhibit_message
+      && !(NILP (args[0]) || (STRINGP (args[0]) && SBYTES (args[0]) == 0))
+      && WINDOW_LIVE_P (Factive_minibuffer_window ())
+      && WINDOW_LIVE_P (Fold_selected_window ())
+      && BUFFERP (Fwindow_buffer (Fold_selected_window ()))
+      && !NILP (Fminibufferp (Fwindow_buffer (Fold_selected_window ()))))
+    {
+      ptrdiff_t count = SPECPDL_INDEX ();
+      /* Avoid possible recursion.  */
+      specbind (Qmessage_in_echo_area, Qt);
+      record_unwind_current_buffer ();
+      Fset_buffer (Fwindow_buffer (Fold_selected_window ()));
+      return unbind_to (count, CALLN (Fapply, intern ("minibuffer-message"),
+                                      Flist (nargs, args)));
+    }
+  else
+    return Fmessage_in_echo_area (nargs, args);
+DEFUN ("message-in-echo-area", Fmessage_in_echo_area, Smessage_in_echo_area, 
1, MANY, 0,
+       doc: /* Display a message at the bottom of the screen.
+The message also goes into the `*Messages*' buffer, if `message-log-max'
+is non-nil.  (In keyboard macros, that's all it does.)
+Return the message.
+In batch mode, the message is printed to the standard error stream,
+followed by a newline.
+The first argument is a format control string, and the rest are data
+to be formatted under control of the string.  Percent sign (%), grave
+accent (\\=`) and apostrophe (\\=') are special in the format; see
+`format-message' for details.  To display STRING without special
+treatment, use (message-in-echo-area "%s" STRING).
+If the first argument is nil or the empty string, the function clears
+any existing message; this lets the minibuffer contents show.  See
+also `current-message'.
+usage: (message-in-echo-area FORMAT-STRING &rest ARGS)  */)
+  (ptrdiff_t nargs, Lisp_Object *args)
   if (NILP (args[0])
       || (STRINGP (args[0])
          && SBYTES (args[0]) == 0))
@@ -4520,6 +4570,11 @@ This variable is experimental; email address@hidden if 
you need
 it to be non-nil.  */);
   binary_as_unsigned = false;
+  DEFVAR_LISP ("message-in-echo-area", Vmessage_in_echo_area,
+              doc: /* Non-nil means overwrite the minibuffer with a message in 
the echo area.  */);
+  Vmessage_in_echo_area = Qnil;
+  DEFSYM (Qmessage_in_echo_area, "message-in-echo-area");
   defsubr (&Spropertize);
   defsubr (&Schar_equal);
   defsubr (&Sgoto_char);
@@ -4594,6 +4649,7 @@ it to be non-nil.  */);
   defsubr (&Semacs_pid);
   defsubr (&Ssystem_name);
   defsubr (&Smessage);
+  defsubr (&Smessage_in_echo_area);
   defsubr (&Smessage_box);
   defsubr (&Smessage_or_box);
   defsubr (&Scurrent_message);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]