diff options
| author | Juri Linkov | 2019-12-22 00:02:10 +0200 |
|---|---|---|
| committer | Juri Linkov | 2019-12-22 00:02:10 +0200 |
| commit | 485b423e8f0df2711a850be7f254665f64ab0bdb (patch) | |
| tree | 02f294b4daa4ec7718769afe8235a7119b52bcb5 /src | |
| parent | 678a71ea2d044f19f75e3f45c930c5e3b707e3dc (diff) | |
| download | emacs-485b423e8f0df2711a850be7f254665f64ab0bdb.tar.gz emacs-485b423e8f0df2711a850be7f254665f64ab0bdb.zip | |
New variable set-message-function to show message at the end of the minibuffer
* doc/lispref/display.texi (Displaying Messages): Document
set-message-function and clear-message-function.
* lisp/minibuffer.el (minibuffer-message-clear-timeout): New defcustom.
(minibuffer-message-timer, minibuffer-message-overlay): New variables.
(set-minibuffer-message, clear-minibuffer-message): New functions.
(set-message-function, clear-message-function): Set variables to
set-minibuffer-message and clear-minibuffer-message respectively.
* src/keyboard.c (read_char): Call clear_message when
Vclear_message_function is a function.
* src/xdisp.c (set_message): Call Vset_message_function when it's a function.
(clear_message): Call Vclear_message_function when it's a function.
(syms_of_xdisp): New variables set-message-function and clear-message-function
(bug#38457).
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 2 | ||||
| -rw-r--r-- | src/xdisp.c | 55 |
2 files changed, 53 insertions, 4 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index 5135fd0bc84..4cf1f64b487 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -2990,6 +2990,8 @@ read_char (int commandflag, Lisp_Object map, | |||
| 2990 | safe_run_hooks (Qecho_area_clear_hook); | 2990 | safe_run_hooks (Qecho_area_clear_hook); |
| 2991 | clear_message (1, 0); | 2991 | clear_message (1, 0); |
| 2992 | } | 2992 | } |
| 2993 | else if (FUNCTIONP (Vclear_message_function)) | ||
| 2994 | clear_message (1, 0); | ||
| 2993 | } | 2995 | } |
| 2994 | 2996 | ||
| 2995 | reread_for_input_method: | 2997 | reread_for_input_method: |
diff --git a/src/xdisp.c b/src/xdisp.c index 08c6927052c..8cba5c5028d 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -11706,13 +11706,32 @@ truncate_message_1 (ptrdiff_t nchars, Lisp_Object a2) | |||
| 11706 | static void | 11706 | static void |
| 11707 | set_message (Lisp_Object string) | 11707 | set_message (Lisp_Object string) |
| 11708 | { | 11708 | { |
| 11709 | Lisp_Object message = Qnil; | ||
| 11710 | |||
| 11709 | eassert (STRINGP (string)); | 11711 | eassert (STRINGP (string)); |
| 11710 | 11712 | ||
| 11711 | message_enable_multibyte = STRING_MULTIBYTE (string); | 11713 | if (FUNCTIONP (Vset_message_function)) |
| 11714 | { | ||
| 11715 | ptrdiff_t count = SPECPDL_INDEX (); | ||
| 11716 | specbind (Qinhibit_quit, Qt); | ||
| 11717 | message = safe_call1 (Vset_message_function, string); | ||
| 11718 | unbind_to (count, Qnil); | ||
| 11712 | 11719 | ||
| 11713 | with_echo_area_buffer (0, -1, set_message_1, 0, string); | 11720 | if (STRINGP (message)) |
| 11714 | message_buf_print = false; | 11721 | { |
| 11715 | help_echo_showing_p = false; | 11722 | string = message; |
| 11723 | message = Qnil; | ||
| 11724 | } | ||
| 11725 | } | ||
| 11726 | |||
| 11727 | if (NILP (message)) | ||
| 11728 | { | ||
| 11729 | message_enable_multibyte = STRING_MULTIBYTE (string); | ||
| 11730 | |||
| 11731 | with_echo_area_buffer (0, -1, set_message_1, 0, string); | ||
| 11732 | message_buf_print = false; | ||
| 11733 | help_echo_showing_p = false; | ||
| 11734 | } | ||
| 11716 | 11735 | ||
| 11717 | if (STRINGP (Vdebug_on_message) | 11736 | if (STRINGP (Vdebug_on_message) |
| 11718 | && STRINGP (string) | 11737 | && STRINGP (string) |
| @@ -11768,6 +11787,14 @@ clear_message (bool current_p, bool last_displayed_p) | |||
| 11768 | { | 11787 | { |
| 11769 | echo_area_buffer[0] = Qnil; | 11788 | echo_area_buffer[0] = Qnil; |
| 11770 | message_cleared_p = true; | 11789 | message_cleared_p = true; |
| 11790 | |||
| 11791 | if (FUNCTIONP (Vclear_message_function)) | ||
| 11792 | { | ||
| 11793 | ptrdiff_t count = SPECPDL_INDEX (); | ||
| 11794 | specbind (Qinhibit_quit, Qt); | ||
| 11795 | safe_call (1, Vclear_message_function); | ||
| 11796 | unbind_to (count, Qnil); | ||
| 11797 | } | ||
| 11771 | } | 11798 | } |
| 11772 | 11799 | ||
| 11773 | if (last_displayed_p) | 11800 | if (last_displayed_p) |
| @@ -34940,6 +34967,26 @@ display table takes effect; in this case, Emacs does not consult | |||
| 34940 | doc: /* If non-nil, debug if a message matching this regexp is displayed. */); | 34967 | doc: /* If non-nil, debug if a message matching this regexp is displayed. */); |
| 34941 | Vdebug_on_message = Qnil; | 34968 | Vdebug_on_message = Qnil; |
| 34942 | 34969 | ||
| 34970 | DEFVAR_LISP ("set-message-function", Vset_message_function, | ||
| 34971 | doc: /* If non-nil, function to show the message. | ||
| 34972 | The function is called with one argument that is the message. | ||
| 34973 | When this function returns nil, the message is displayed in the echo | ||
| 34974 | area as usual. When the function returns a string, the returned | ||
| 34975 | string is displayed in the echo area. When this function returns | ||
| 34976 | other non-nil values, this means that the message was handled | ||
| 34977 | specially, so the same message is not displayed in the echo area. | ||
| 34978 | See also `clear-message-function' that can be used to clear the | ||
| 34979 | message displayed by this function. */); | ||
| 34980 | Vset_message_function = Qnil; | ||
| 34981 | |||
| 34982 | DEFVAR_LISP ("clear-message-function", Vclear_message_function, | ||
| 34983 | doc: /* If non-nil, function to clear message. | ||
| 34984 | Usually this function is called when the next input event arrives. | ||
| 34985 | The function is called without arguments. It is expected to clear the | ||
| 34986 | message displayed by its counterpart function specified by | ||
| 34987 | `set-message-function'. */); | ||
| 34988 | Vclear_message_function = Qnil; | ||
| 34989 | |||
| 34943 | DEFVAR_LISP ("redisplay--all-windows-cause", Vredisplay__all_windows_cause, | 34990 | DEFVAR_LISP ("redisplay--all-windows-cause", Vredisplay__all_windows_cause, |
| 34944 | doc: /* */); | 34991 | doc: /* */); |
| 34945 | Vredisplay__all_windows_cause = Fmake_hash_table (0, NULL); | 34992 | Vredisplay__all_windows_cause = Fmake_hash_table (0, NULL); |