GNU bug report logs - #52314
Set message functions

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Juri Linkov <juri@HIDDEN>; Keywords: patch; dated Sun, 5 Dec 2021 19:12:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 52314 <at> debbugs.gnu.org:


Received: (at 52314) by debbugs.gnu.org; 6 Dec 2021 01:27:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 05 20:27:21 2021
Received: from localhost ([127.0.0.1]:60078 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mu2mm-0000V9-WA
	for submit <at> debbugs.gnu.org; Sun, 05 Dec 2021 20:27:21 -0500
Received: from mail-pg1-f169.google.com ([209.85.215.169]:40890)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stefankangas@HIDDEN>) id 1mu2mk-0000Ui-Qz
 for 52314 <at> debbugs.gnu.org; Sun, 05 Dec 2021 20:27:19 -0500
Received: by mail-pg1-f169.google.com with SMTP id l190so8931963pge.7
 for <52314 <at> debbugs.gnu.org>; Sun, 05 Dec 2021 17:27:18 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:in-reply-to:references:user-agent
 :mime-version:date:message-id:subject:to:cc;
 bh=6MqYL6B2Inzl9JkrJQEPcVfncPdorIPeoUFx9M75mMw=;
 b=6XODmVcXY9RPhh4asOG2IL74Uugh0CTByVNJosvSjIWJjQUJxdqYcCIf+PxNpXAMfJ
 7k0Ue0mPnRz9vNOdJxSJ9ZCZB0wv890WXuIP5KopVowcGXPxDYmwYwPQ15Mhj1ICpvQ2
 1osAnlfhAsDtK7KabqDTCuqyO47LSH0H+5cSmh7pxoMN7xbf/gZoRAlhrTzOEbsUACcW
 L8ylCZclinR1XLRG1ggWYeFl3dYpd2z5mcKjGmKwazpi0yuYhEbE6RzkEsNRr4zKhMgW
 M9OgP0NwZFwXIaHRFTxsjIaMiKF5tBF0RMA4s4XrvSbq7GDY8xWR+OZYEDhMBsZBSWsp
 EgSg==
X-Gm-Message-State: AOAM530Eu/XF1DGosEnQCo5vFd0bsInYZO9U8uPFXY3FGcdSpXsaG5uD
 uTJpXvwe0Lmj+2kvAOewBy70GTn8sx/XCorWOHPQJt0u
X-Google-Smtp-Source: ABdhPJxj8FMTh0AzbQXdgOgB7oqfSZPZ47MUlVkduf7znavVA6gydE6DqtORfS9bpybcymk1bI1l5EBcY7ecf9GeabA=
X-Received: by 2002:a62:1a03:0:b0:494:64b5:3e01 with SMTP id
 a3-20020a621a03000000b0049464b53e01mr33835420pfa.35.1638754032945; Sun, 05
 Dec 2021 17:27:12 -0800 (PST)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Mon, 6 Dec 2021 02:27:12 +0100
From: Stefan Kangas <stefan@HIDDEN>
In-Reply-To: <864k7m3m69.fsf@HIDDEN> (Juri Linkov's message of "Sun, 
 05 Dec 2021 21:07:42 +0200")
References: <864k7m3m69.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Date: Mon, 6 Dec 2021 02:27:12 +0100
Message-ID: <CADwFkmmfRhznQftWqznk8dV6qwJxb6RHJv9ewHrkrq1YcS=BKA@HIDDEN>
Subject: Re: bug#52314: Set message functions
To: Juri Linkov <juri@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 52314
Cc: 52314 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

Juri Linkov <juri@HIDDEN> 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@HIDDEN:
bug#52314; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 5 Dec 2021 19:11:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 05 14:11:54 2021
Received: from localhost ([127.0.0.1]:59470 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mtwvS-0002D3-Db
	for submit <at> debbugs.gnu.org; Sun, 05 Dec 2021 14:11:54 -0500
Received: from lists.gnu.org ([209.51.188.17]:40064)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@HIDDEN>) id 1mtwvR-0002Cu-IQ
 for submit <at> debbugs.gnu.org; Sun, 05 Dec 2021 14:11:53 -0500
Received: from eggs.gnu.org ([209.51.188.92]:50140)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <juri@HIDDEN>) id 1mtwvR-0006VF-Df
 for bug-gnu-emacs@HIDDEN; Sun, 05 Dec 2021 14:11:53 -0500
Received: from relay9-d.mail.gandi.net ([217.70.183.199]:56963)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <juri@HIDDEN>) id 1mtwvP-0004L3-0N
 for bug-gnu-emacs@HIDDEN; Sun, 05 Dec 2021 14:11:53 -0500
Received: (Authenticated sender: juri@HIDDEN)
 by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 4E253FF807
 for <bug-gnu-emacs@HIDDEN>; Sun,  5 Dec 2021 19:11:47 +0000 (UTC)
From: Juri Linkov <juri@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: Set message functions
Organization: LINKOV.NET
Date: Sun, 05 Dec 2021 21:07:42 +0200
Message-ID: <864k7m3m69.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=217.70.183.199; envelope-from=juri@HIDDEN;
 helo=relay9-d.mail.gandi.net
X-Spam_score_int: -25
X-Spam_score: -2.6
X-Spam_bar: --
X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7,
 RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)

--=-=-=
Content-Type: text/plain

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:


--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline; filename=set-message-functions.patch

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.

--=-=-=--




Acknowledgement sent to Juri Linkov <juri@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#52314; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 6 Dec 2021 01:30:02 UTC

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