diff options
| author | Eli Zaretskii | 2023-04-01 12:49:18 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2023-04-01 12:49:18 +0300 |
| commit | d1d39a0f09c272a8bdea54ecd13f560bbd8264eb (patch) | |
| tree | ada0a337b2b2007176e72808eb0784a3e2c7b7c7 | |
| parent | 46209b2453b1a53fcf0019f6e1a21b7fef85bcbc (diff) | |
| download | emacs-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.texi | 74 | ||||
| -rw-r--r-- | etc/NEWS | 15 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 26 |
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 | ||
| 313 | The following facilities allow users and Lisp programs to control how | ||
| 314 | echo-area messages are displayed. | ||
| 315 | |||
| 313 | @defvar set-message-function | 316 | @defvar set-message-function |
| 314 | If this variable is non-@code{nil}, it should be a function of one | 317 | If this variable is non-@code{nil}, it should be a function of one |
| 315 | argument, the text of a message to display in the echo area. This | 318 | argument, the text of a message to display in the echo area. That |
| 316 | function will be called by @code{message} and related functions. If | 319 | function will be called by @code{message} and related functions. If |
| 317 | the function returns @code{nil}, the message is displayed in the echo | 320 | the function returns @code{nil}, the message is displayed in the echo |
| 318 | area as usual. If this function returns a string, that string is | 321 | area as usual. If the function returns a string, that string is |
| 319 | displayed in the echo area instead of the original one. If this | 322 | displayed in the echo area @emph{instead} of the original message. If |
| 320 | function returns other non-@code{nil} values, that means the message | 323 | the function returns any other non-@code{nil} value, that means the |
| 321 | was already handled, so @code{message} will not display anything in | 324 | message was already handled, so @code{message} will not display |
| 322 | the echo area. See also @code{clear-message-function} that can be | 325 | anything in the echo area. |
| 323 | used to clear the message displayed by this function. | 326 | |
| 324 | 327 | The default value calls @code{set-minibuffer-message}, described | |
| 325 | The default value is the function that displays the message at the end | 328 | below. |
| 326 | of the minibuffer when the minibuffer is active. However, if the text | ||
| 327 | shown in the active minibuffer has the @code{minibuffer-message} text | ||
| 328 | property (@pxref{Special Properties}) on some character, the message | ||
| 329 | will 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 |
| 333 | If this variable is non-@code{nil}, @code{message} and related | 332 | If this variable is non-@code{nil}, it should be a function of no |
| 334 | functions call it with no arguments when their argument message is | 333 | arguments; @code{message} and related functions call it when their |
| 335 | @code{nil} or the empty string. | 334 | argument message is @code{nil} or the empty string, to clear the echo |
| 335 | area. | ||
| 336 | 336 | ||
| 337 | Usually this function is called when the next input event arrives | 337 | Usually this function is called when the next input event arrives |
| 338 | after displaying an echo-area message. The function is expected to | 338 | after 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 | |||
| 358 | function returns a non-@code{nil} value that is not a string, the | 358 | function returns a non-@code{nil} value that is not a string, the |
| 359 | message is considered to be handled, and no further functions in the | 359 | message is considered to be handled, and no further functions in the |
| 360 | list are called. | 360 | list are called. |
| 361 | |||
| 362 | The three useful functions to be put in the list that is the value of | ||
| 363 | this option are described below. | ||
| 361 | @end defopt | 364 | @end defopt |
| 362 | 365 | ||
| 366 | @defun set-minibuffer-message message | ||
| 367 | This function displays @var{message} in the echo-area when the | ||
| 368 | minibuffer is not active, and at the end of the minibuffer when the | ||
| 369 | minibuffer is active. However, if the text shown in the active | ||
| 370 | minibuffer has the @code{minibuffer-message} text property | ||
| 371 | (@pxref{Special Properties}) on some character, the message will be | ||
| 372 | displayed before the first character having that property. | ||
| 373 | |||
| 374 | This 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 | ||
| 380 | If an echo-area @var{message} matches any regexp in the list that is | ||
| 381 | the value of the user option @code{inhibit-message-regexps}, this | ||
| 382 | function suppresses the display of that message and returns a | ||
| 383 | non-@code{nil} value that is not a string. Thus, if this function is | ||
| 384 | in the list @code{set-message-functions}, the rest of the functions in | ||
| 385 | the list will not be called when @var{message} matches the regexps in | ||
| 386 | @code{inhibit-message-regexps}. To ensure a matching @var{message} | ||
| 387 | will never be displayed, make this function be the first element of | ||
| 388 | the 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 | ||
| 394 | This function accumulates several echo-area messages emitted one after | ||
| 395 | another, and returns them as a single string in which individual | ||
| 396 | messages are separated by newlines. Up to @code{multi-message-max} | ||
| 397 | recent messages can be accumulated. The accumulated messages are | ||
| 398 | discarded when more than @code{multi-message-timeout} seconds have | ||
| 399 | elapsed since the time the first message was emitted. | ||
| 400 | @end defun | ||
| 401 | |||
| 363 | @defvar inhibit-message | 402 | @defvar inhibit-message |
| 364 | When this variable is non-@code{nil}, @code{message} and related functions | 403 | When this variable is non-@code{nil}, @code{message} and related functions |
| 365 | will not use the Echo Area to display messages. | 404 | will not display any messages in the Echo Area. Echo-area messages |
| 405 | are 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 |
| @@ -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'. |
| 798 | It allows selecting more functions for 'set-message-function' | 798 | It allows more flexible control of how echo-area message are displayed |
| 799 | in addition to the default function that handles messages | 799 | by adding functions to this list. The default value is a list of one |
| 800 | in the active minibuffer. The most useful are 'inhibit-message' | 800 | element: 'set-minibuffer-message', which displays echo-area messages |
| 801 | that allows specifying a list of messages to inhibit via | 801 | at the end of the minibuffer text when the minibuffer is active. |
| 802 | 'inhibit-message-regexps', and 'set-multi-message' that | 802 | Other useful functions include 'inhibit-message', which allows |
| 803 | accumulates recent messages and displays them stacked | 803 | specifying, via 'inhibit-message-regexps', the list of messages whose |
| 804 | in the echo area. | 804 | display shall be inhibited; and 'set-multi-message' that accumulates |
| 805 | recent 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 | |||
| 862 | next function in the list, and if the last function returns a string, | 862 | next function in the list, and if the last function returns a string, |
| 863 | it's displayed in the echo area. | 863 | it's displayed in the echo area. |
| 864 | If a function returns any other non-nil value, no more functions are | 864 | If a function returns any other non-nil value, no more functions are |
| 865 | called from the list, and no message will be displayed in the echo area." | 865 | called from the list, and no message will be displayed in the echo area. |
| 866 | |||
| 867 | Useful 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'. |
| 899 | When the list in `set-message-functions' has `inhibit-message' as its | ||
| 900 | first element, echo-area messages which match the value of this variable | ||
| 901 | will 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'. |
| 893 | This function is intended to be added to `set-message-functions'." | 907 | This function is intended to be added to `set-message-functions'. |
| 908 | To suppress display of echo-area messages that match `inhibit-message-regexps', | ||
| 909 | make 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. |
| 931 | Individual messages will be separated by a newline. | ||
| 932 | Up to `multi-message-max' messages can be accumulated, and the | ||
| 933 | accumulated messages are discarded when `multi-message-timeout' | ||
| 934 | seconds have elapsed since the first message. | ||
| 915 | Note that this feature works best only when `resize-mini-windows' | 935 | Note that this feature works best only when `resize-mini-windows' |
| 916 | is at its default value `grow-only'." | 936 | is at its default value `grow-only'." |
| 917 | (let ((last-message (car multi-message-list))) | 937 | (let ((last-message (car multi-message-list))) |