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

* bug#52314: Set message functions
  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-09-08 14:43 ` Lars Ingebrigtsen
  1 sibling, 1 reply; 8+ messages in thread
From: Stefan Kangas @ 2021-12-06  1:27 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 52314

Juri Linkov <juri@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.





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

* bug#52314: Set message functions
  2021-12-06  1:27 ` Stefan Kangas
@ 2021-12-06  9:35   ` Juri Linkov
  2022-11-11 13:38     ` Stefan Kangas
  0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2021-12-06  9:35 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 52314

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





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

* bug#52314: Set message functions
  2021-12-05 19:07 bug#52314: Set message functions Juri Linkov
  2021-12-06  1:27 ` Stefan Kangas
@ 2022-09-08 14:43 ` Lars Ingebrigtsen
  1 sibling, 0 replies; 8+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-08 14:43 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 52314

Juri Linkov <juri@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.





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

* bug#52314: Set message functions
  2021-12-06  9:35   ` Juri Linkov
@ 2022-11-11 13:38     ` Stefan Kangas
  2022-11-12 17:40       ` Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Kangas @ 2022-11-11 13:38 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 52314

tags 52314 - patch
thanks

Juri Linkov <juri@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.





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

* bug#52314: Set message functions
  2022-11-11 13:38     ` Stefan Kangas
@ 2022-11-12 17:40       ` Juri Linkov
  2022-11-12 19:41         ` Stefan Kangas
  0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2022-11-12 17:40 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 52314

>>>> +(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.





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

* bug#52314: Set message functions
  2022-11-12 17:40       ` Juri Linkov
@ 2022-11-12 19:41         ` Stefan Kangas
  2022-11-13 18:58           ` Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Kangas @ 2022-11-12 19:41 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 52314

tags 52314 + patch
thanks

Juri Linkov <juri@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.  :-)





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

* bug#52314: Set message functions
  2022-11-12 19:41         ` Stefan Kangas
@ 2022-11-13 18:58           ` Juri Linkov
  0 siblings, 0 replies; 8+ messages in thread
From: Juri Linkov @ 2022-11-13 18:58 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 52314

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.





^ permalink raw reply	[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).