From: Juri Linkov <juri@linkov.net>
To: 52314@debbugs.gnu.org
Subject: bug#52314: Set message functions
Date: Sun, 05 Dec 2021 21:07:42 +0200 [thread overview]
Message-ID: <864k7m3m69.fsf@mail.linkov.net> (raw)
[-- 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.
next reply other threads:[~2021-12-05 19:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-05 19:07 Juri Linkov [this message]
2021-12-06 1:27 ` bug#52314: Set message functions 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=864k7m3m69.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=52314@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).