GNU bug report logs - #52314
Set message functions

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Sun, 5 Dec 2021 19:12:01 UTC

Severity: wishlist

Tags: patch

Fixed in version 29.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 52314 in the body.
You can then email your comments to 52314 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#52314; Package emacs. (Sun, 05 Dec 2021 19:12:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> linkov.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 05 Dec 2021 19:12:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: bug-gnu-emacs <at> gnu.org
Subject: Set message functions
Date: Sun, 05 Dec 2021 21:07:42 +0200
[Message part 1 (text/plain, inline)]
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:

[set-message-functions.patch (text/x-diff, inline)]
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.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52314; Package emacs. (Mon, 06 Dec 2021 01:28:01 GMT) Full text and rfc822 format available.

Message #8 received at 52314 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Juri Linkov <juri <at> linkov.net>
Cc: 52314 <at> debbugs.gnu.org
Subject: Re: bug#52314: Set message functions
Date: Mon, 6 Dec 2021 02:27:12 +0100
Juri Linkov <juri <at> linkov.net> writes:

> To address several requests, there is a patch for Emacs 29 that supports:
[snip]

Cool!

> +(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")

How about making this optionally support a list as well?  That would
make it slightly easier to customize with `M-x customize', I think,
especially once you start racking up many ignored messages.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52314; Package emacs. (Mon, 06 Dec 2021 09:40:03 GMT) Full text and rfc822 format available.

Message #11 received at 52314 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: 52314 <at> debbugs.gnu.org
Subject: Re: bug#52314: Set message functions
Date: Mon, 06 Dec 2021 11:35:18 +0200
>> +(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")
>
> How about making this optionally support a list as well?  That would
> make it slightly easier to customize with `M-x customize', I think,
> especially once you start racking up many ignored messages.

Thanks, good idea, will add it in the next version of the patch.
Also this will help to add more regexps easier with e.g.:

  (add-to-list 'inhibit-message-regexps "^Mark set$")




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52314; Package emacs. (Thu, 08 Sep 2022 14:44:01 GMT) Full text and rfc822 format available.

Message #14 received at 52314 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 52314 <at> debbugs.gnu.org
Subject: Re: bug#52314: Set message functions
Date: Thu, 08 Sep 2022 16:43:33 +0200
Juri Linkov <juri <at> linkov.net> writes:

> 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:

Hm...  the patch only had the defcustom and some helper functions, so
was this just to get feedback on the interface?

If so, I think it looks good -- but I'm a bit vague about what
set-multi-message would look like.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52314; Package emacs. (Fri, 11 Nov 2022 13:39:01 GMT) Full text and rfc822 format available.

Message #17 received at 52314 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 52314 <at> debbugs.gnu.org
Subject: Re: bug#52314: Set message functions
Date: Fri, 11 Nov 2022 05:38:45 -0800
tags 52314 - patch
thanks

Juri Linkov <juri <at> linkov.net> writes:

>>> +(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")
>>
>> How about making this optionally support a list as well?  That would
>> make it slightly easier to customize with `M-x customize', I think,
>> especially once you start racking up many ignored messages.
>
> Thanks, good idea, will add it in the next version of the patch.
> Also this will help to add more regexps easier with e.g.:
>
>   (add-to-list 'inhibit-message-regexps "^Mark set$")

I'm removing the patch tag for now, as it seems like this is not yet
ready for installing on master.




Removed tag(s) patch. Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Fri, 11 Nov 2022 13:39:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52314; Package emacs. (Sat, 12 Nov 2022 18:11:01 GMT) Full text and rfc822 format available.

Message #22 received at 52314 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 52314 <at> debbugs.gnu.org
Subject: Re: bug#52314: Set message functions
Date: Sat, 12 Nov 2022 19:40:52 +0200
>>>> +(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")
>>>
>>> How about making this optionally support a list as well?  That would
>>> make it slightly easier to customize with `M-x customize', I think,
>>> especially once you start racking up many ignored messages.
>>
>> Thanks, good idea, will add it in the next version of the patch.
>> Also this will help to add more regexps easier with e.g.:
>>
>>   (add-to-list 'inhibit-message-regexps "^Mark set$")
>
> I'm removing the patch tag for now, as it seems like this is not yet
> ready for installing on master.

Why not?  I have been testing this patch for 1.5 years, and
everything works fine.  So it's ready for installing on master.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52314; Package emacs. (Sat, 12 Nov 2022 19:42:02 GMT) Full text and rfc822 format available.

Message #25 received at 52314 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 52314 <at> debbugs.gnu.org
Subject: Re: bug#52314: Set message functions
Date: Sat, 12 Nov 2022 11:41:45 -0800
tags 52314 + patch
thanks

Juri Linkov <juri <at> linkov.net> writes:

>> I'm removing the patch tag for now, as it seems like this is not yet
>> ready for installing on master.
>
> Why not?  I have been testing this patch for 1.5 years, and
> everything works fine.  So it's ready for installing on master.

I thought there was more to do?  If I misunderstood, even better.

Then you can consider this a reminder to please install this.  :-)




Added tag(s) patch. Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Sat, 12 Nov 2022 19:42:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52314; Package emacs. (Sun, 13 Nov 2022 19:00:02 GMT) Full text and rfc822 format available.

Message #30 received at 52314 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 52314 <at> debbugs.gnu.org
Subject: Re: bug#52314: Set message functions
Date: Sun, 13 Nov 2022 20:58:44 +0200
close 52314 29.0.50
thanks

>>> I'm removing the patch tag for now, as it seems like this is not yet
>>> ready for installing on master.
>>
>> Why not?  I have been testing this patch for 1.5 years, and
>> everything works fine.  So it's ready for installing on master.
>
> I thought there was more to do?  If I misunderstood, even better.
>
> Then you can consider this a reminder to please install this.  :-)

Sorry, only now I noticed that I forgot to send a newer patch
that implemented your suggestion to rename inhibit-message-regexp
to inhibit-message-regexps.  I have tested it for a long time,
so now it's pushed in the commit 9d5fc2c7eb.




bug marked as fixed in version 29.0.50, send any further explanations to 52314 <at> debbugs.gnu.org and Juri Linkov <juri <at> linkov.net> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Sun, 13 Nov 2022 19:00:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 12 Dec 2022 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 107 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.