aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2023-04-01 12:49:18 +0300
committerEli Zaretskii2023-04-01 12:49:18 +0300
commitd1d39a0f09c272a8bdea54ecd13f560bbd8264eb (patch)
treeada0a337b2b2007176e72808eb0784a3e2c7b7c7
parent46209b2453b1a53fcf0019f6e1a21b7fef85bcbc (diff)
downloademacs-d1d39a0f09c272a8bdea54ecd13f560bbd8264eb.tar.gz
emacs-d1d39a0f09c272a8bdea54ecd13f560bbd8264eb.zip
Document enhancements in handling of echo-area messages
* etc/NEWS: * doc/lispref/display.texi (Displaying Messages): * lisp/minibuffer.el (inhibit-message-regexps) (set-message-functions, inhibit-message, set-multi-message): Improve the documentation of functions dealing with display of echo-area messages.
-rw-r--r--doc/lispref/display.texi74
-rw-r--r--etc/NEWS15
-rw-r--r--lisp/minibuffer.el26
3 files changed, 88 insertions, 27 deletions
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 550d711c73a..85fac4b30a6 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -310,29 +310,29 @@ reformatted, with undesirable results. Instead, use @code{(message
310"%s" @var{string})}. 310"%s" @var{string})}.
311@end defun 311@end defun
312 312
313The following facilities allow users and Lisp programs to control how
314echo-area messages are displayed.
315
313@defvar set-message-function 316@defvar set-message-function
314If this variable is non-@code{nil}, it should be a function of one 317If this variable is non-@code{nil}, it should be a function of one
315argument, the text of a message to display in the echo area. This 318argument, the text of a message to display in the echo area. That
316function will be called by @code{message} and related functions. If 319function will be called by @code{message} and related functions. If
317the function returns @code{nil}, the message is displayed in the echo 320the function returns @code{nil}, the message is displayed in the echo
318area as usual. If this function returns a string, that string is 321area as usual. If the function returns a string, that string is
319displayed in the echo area instead of the original one. If this 322displayed in the echo area @emph{instead} of the original message. If
320function returns other non-@code{nil} values, that means the message 323the function returns any other non-@code{nil} value, that means the
321was already handled, so @code{message} will not display anything in 324message was already handled, so @code{message} will not display
322the echo area. See also @code{clear-message-function} that can be 325anything in the echo area.
323used to clear the message displayed by this function. 326
324 327The default value calls @code{set-minibuffer-message}, described
325The default value is the function that displays the message at the end 328below.
326of the minibuffer when the minibuffer is active. However, if the text
327shown in the active minibuffer has the @code{minibuffer-message} text
328property (@pxref{Special Properties}) on some character, the message
329will be displayed before the first character having that property.
330@end defvar 329@end defvar
331 330
332@defvar clear-message-function 331@defvar clear-message-function
333If this variable is non-@code{nil}, @code{message} and related 332If this variable is non-@code{nil}, it should be a function of no
334functions call it with no arguments when their argument message is 333arguments; @code{message} and related functions call it when their
335@code{nil} or the empty string. 334argument message is @code{nil} or the empty string, to clear the echo
335area.
336 336
337Usually this function is called when the next input event arrives 337Usually this function is called when the next input event arrives
338after displaying an echo-area message. The function is expected to 338after displaying an echo-area message. The function is expected to
@@ -358,11 +358,51 @@ with the same text; if the last function in the list returns
358function returns a non-@code{nil} value that is not a string, the 358function returns a non-@code{nil} value that is not a string, the
359message is considered to be handled, and no further functions in the 359message is considered to be handled, and no further functions in the
360list are called. 360list are called.
361
362The three useful functions to be put in the list that is the value of
363this option are described below.
361@end defopt 364@end defopt
362 365
366@defun set-minibuffer-message message
367This function displays @var{message} in the echo-area when the
368minibuffer is not active, and at the end of the minibuffer when the
369minibuffer is active. However, if the text shown in the active
370minibuffer has the @code{minibuffer-message} text property
371(@pxref{Special Properties}) on some character, the message will be
372displayed before the first character having that property.
373
374This function is by default the only member of the list in
375@code{set-message-functions}.
376@end defun
377
378@vindex inhibit-message-regexps
379@defun inhibit-message message
380If an echo-area @var{message} matches any regexp in the list that is
381the value of the user option @code{inhibit-message-regexps}, this
382function suppresses the display of that message and returns a
383non-@code{nil} value that is not a string. Thus, if this function is
384in the list @code{set-message-functions}, the rest of the functions in
385the list will not be called when @var{message} matches the regexps in
386@code{inhibit-message-regexps}. To ensure a matching @var{message}
387will never be displayed, make this function be the first element of
388the list in @code{set-message-functions}.
389@end defun
390
391@vindex multi-message-max
392@vindex multi-message-timeout
393@defun set-multi-message message
394This function accumulates several echo-area messages emitted one after
395another, and returns them as a single string in which individual
396messages are separated by newlines. Up to @code{multi-message-max}
397recent messages can be accumulated. The accumulated messages are
398discarded when more than @code{multi-message-timeout} seconds have
399elapsed since the time the first message was emitted.
400@end defun
401
363@defvar inhibit-message 402@defvar inhibit-message
364When this variable is non-@code{nil}, @code{message} and related functions 403When this variable is non-@code{nil}, @code{message} and related functions
365will not use the Echo Area to display messages. 404will not display any messages in the Echo Area. Echo-area messages
405are still logged in the @file{*Messages*} buffer, though.
366@end defvar 406@end defvar
367 407
368@defmac with-temp-message message &rest body 408@defmac with-temp-message message &rest body
diff --git a/etc/NEWS b/etc/NEWS
index d7a6cf7986d..e43a82b1426 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -795,13 +795,14 @@ part of the buffer.
795 795
796+++ 796+++
797** New user option 'set-message-functions'. 797** New user option 'set-message-functions'.
798It allows selecting more functions for 'set-message-function' 798It allows more flexible control of how echo-area message are displayed
799in addition to the default function that handles messages 799by adding functions to this list. The default value is a list of one
800in the active minibuffer. The most useful are 'inhibit-message' 800element: 'set-minibuffer-message', which displays echo-area messages
801that allows specifying a list of messages to inhibit via 801at the end of the minibuffer text when the minibuffer is active.
802'inhibit-message-regexps', and 'set-multi-message' that 802Other useful functions include 'inhibit-message', which allows
803accumulates recent messages and displays them stacked 803specifying, via 'inhibit-message-regexps', the list of messages whose
804in the echo area. 804display shall be inhibited; and 'set-multi-message' that accumulates
805recent messages and displays them stacked together.
805 806
806--- 807---
807** New user option 'find-library-include-other-files'. 808** New user option 'find-library-include-other-files'.
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 21d4607e7cf..be91987d635 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -862,7 +862,18 @@ If a function returns a string, the returned string is given to the
862next function in the list, and if the last function returns a string, 862next function in the list, and if the last function returns a string,
863it's displayed in the echo area. 863it's displayed in the echo area.
864If a function returns any other non-nil value, no more functions are 864If a function returns any other non-nil value, no more functions are
865called from the list, and no message will be displayed in the echo area." 865called from the list, and no message will be displayed in the echo area.
866
867Useful functions to add to this list are:
868
869 `inhibit-message' -- if this function is the first in the list,
870 messages that match the value of
871 `inhibit-message-regexps' will be suppressed.
872 `set-multi-message' -- accumulate multiple messages and display them
873 together as a single message.
874 `set-minibuffer-message' -- if the minibuffer is active, display the
875 message at the end of the minibuffer text
876 (this is the default)."
866 :type '(choice (const :tag "No special message handling" nil) 877 :type '(choice (const :tag "No special message handling" nil)
867 (repeat 878 (repeat
868 (choice (function-item :tag "Inhibit some messages" 879 (choice (function-item :tag "Inhibit some messages"
@@ -884,13 +895,18 @@ called from the list, and no message will be displayed in the echo area."
884 message) 895 message)
885 896
886(defcustom inhibit-message-regexps nil 897(defcustom inhibit-message-regexps nil
887 "List of regexps that inhibit messages by the function `inhibit-message'." 898 "List of regexps that inhibit messages by the function `inhibit-message'.
899When the list in `set-message-functions' has `inhibit-message' as its
900first element, echo-area messages which match the value of this variable
901will not be displayed."
888 :type '(repeat regexp) 902 :type '(repeat regexp)
889 :version "29.1") 903 :version "29.1")
890 904
891(defun inhibit-message (message) 905(defun inhibit-message (message)
892 "Don't display MESSAGE when it matches the regexp `inhibit-message-regexps'. 906 "Don't display MESSAGE when it matches the regexp `inhibit-message-regexps'.
893This function is intended to be added to `set-message-functions'." 907This function is intended to be added to `set-message-functions'.
908To suppress display of echo-area messages that match `inhibit-message-regexps',
909make this function be the first element of `set-message-functions'."
894 (or (and (consp inhibit-message-regexps) 910 (or (and (consp inhibit-message-regexps)
895 (string-match-p (mapconcat #'identity inhibit-message-regexps "\\|") 911 (string-match-p (mapconcat #'identity inhibit-message-regexps "\\|")
896 message)) 912 message))
@@ -912,6 +928,10 @@ This function is intended to be added to `set-message-functions'."
912 928
913(defun set-multi-message (message) 929(defun set-multi-message (message)
914 "Return recent messages as one string to display in the echo area. 930 "Return recent messages as one string to display in the echo area.
931Individual messages will be separated by a newline.
932Up to `multi-message-max' messages can be accumulated, and the
933accumulated messages are discarded when `multi-message-timeout'
934seconds have elapsed since the first message.
915Note that this feature works best only when `resize-mini-windows' 935Note that this feature works best only when `resize-mini-windows'
916is at its default value `grow-only'." 936is at its default value `grow-only'."
917 (let ((last-message (car multi-message-list))) 937 (let ((last-message (car multi-message-list)))