unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#52314: Set message functions
@ 2021-12-05 19:07 Juri Linkov
  2021-12-06  1:27 ` Stefan Kangas
  2022-09-08 14:43 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 8+ messages in thread
From: Juri Linkov @ 2021-12-05 19:07 UTC (permalink / raw)
  To: 52314

[-- Attachment #1: Type: text/plain, Size: 860 bytes --]

Version: 29.0.50
Severity: wishlist
Tags: patch

To address several requests, there is a patch for Emacs 29 that supports:

1. inhibiting messages selectively like discussed in bug#42865, bug#44629;

2. multi-line accumulated messages like discussed on emacs-devel
   under subject "Intelligent stacking of messages in the echo area";

3. combining all them plus minibuffer messages into a pipeline:
   first inhibit-message can filter out some messages, then the second
   function can accumulate 10 old messages into a multi-line message,
   then the third function will display them in the active minibuffer.

By default, 'set-message-functions' will be '(set-minibuffer-message)'
with the current behavior, but can be customized to
'(inhibit-message set-multi-message set-minibuffer-message)'
to implement the hook-like list of functions described above:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: set-message-functions.patch --]
[-- Type: text/x-diff, Size: 2595 bytes --]

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 0a5fb72774..3eadae88db 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -852,7 +852,51 @@ set-minibuffer-message
         ;; was handled specially by this function.
         t))))
 
-(setq set-message-function 'set-minibuffer-message)
+(setq set-message-function 'set-message-functions)
+
+(defcustom set-message-functions '(set-minibuffer-message)
+  "List of functions to handle display of echo-area messages.
+Each function is called with one argument that is the text of a message.
+If a function returns nil, a previous message string is given to the
+next function in the list, and if the last function returns nil, the
+last message string is displayed in the echo area.
+If a function returns a string, the returned string is given to the
+next function in the list, and if the last function returns a string,
+it's displayed in the echo area.
+If a function returns any other non-nil value, no more functions are
+called from the list, and no message will be displayed in the echo area."
+  :type '(choice (const :tag "No special message handling" nil)
+                 (repeat
+                  (choice (function-item :tag "Inhibit some messages"
+                                         inhibit-message)
+                          (function-item :tag "Accumulate messages"
+                                         set-multi-message)
+                          (function-item :tag "Handle minibuffer"
+                                         set-minibuffer-message)
+                          (function :tag "Custom function"))))
+  :version "29.1")
+
+(defun set-message-functions (message)
+  (run-hook-wrapped 'set-message-functions
+                    (lambda (fun)
+                      (when (stringp message)
+                        (let ((ret (funcall fun message)))
+                          (when ret (setq message ret))))
+                      nil))
+  message)
+
+(defcustom inhibit-message-regexp nil
+  "Regexp to inhibit messages by the function `inhibit-message'."
+  :type '(choice (const :tag "Don't inhibit messages" nil)
+                 (regexp :tag "Inhibit messages that match regexp"))
+  :version "29.1")
+
+(defun inhibit-message (message)
+  "Don't display MESSAGE when it matches the regexp `inhibit-message-regexp'.
+This function is intended to be added to `set-message-functions'."
+  (or (and (stringp inhibit-message-regexp)
+           (string-match-p inhibit-message-regexp message))
+      message))
 
 (defun clear-minibuffer-message ()
   "Clear minibuffer message.

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-11-13 18:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-05 19:07 bug#52314: Set message functions Juri Linkov
2021-12-06  1:27 ` Stefan Kangas
2021-12-06  9:35   ` Juri Linkov
2022-11-11 13:38     ` Stefan Kangas
2022-11-12 17:40       ` Juri Linkov
2022-11-12 19:41         ` Stefan Kangas
2022-11-13 18:58           ` Juri Linkov
2022-09-08 14:43 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).