From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#52314: Set message functions Date: Sun, 05 Dec 2021 21:07:42 +0200 Organization: LINKOV.NET Message-ID: <864k7m3m69.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13683"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) To: 52314@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 05 20:12:31 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mtww1-0003Kx-Ab for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 05 Dec 2021 20:12:29 +0100 Original-Received: from localhost ([::1]:38408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mtwvz-0006Y9-Ua for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 05 Dec 2021 14:12:27 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:50148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mtwva-0006Xo-9E for bug-gnu-emacs@gnu.org; Sun, 05 Dec 2021 14:12:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47924) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mtwva-0004N2-1p for bug-gnu-emacs@gnu.org; Sun, 05 Dec 2021 14:12:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mtwvZ-0002DY-Oc for bug-gnu-emacs@gnu.org; Sun, 05 Dec 2021 14:12:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 05 Dec 2021 19:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 52314 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16387315148506 (code B ref -1); Sun, 05 Dec 2021 19:12:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 Dec 2021 19:11:54 +0000 Original-Received: from localhost ([127.0.0.1]:59470 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mtwvS-0002D3-Db for submit@debbugs.gnu.org; Sun, 05 Dec 2021 14:11:54 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:40064) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mtwvR-0002Cu-IQ for submit@debbugs.gnu.org; Sun, 05 Dec 2021 14:11:53 -0500 Original-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 ) id 1mtwvR-0006VF-Df for bug-gnu-emacs@gnu.org; Sun, 05 Dec 2021 14:11:53 -0500 Original-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 ) id 1mtwvP-0004L3-0N for bug-gnu-emacs@gnu.org; Sun, 05 Dec 2021 14:11:53 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 4E253FF807 for ; Sun, 5 Dec 2021 19:11:47 +0000 (UTC) Received-SPF: pass client-ip=217.70.183.199; envelope-from=juri@linkov.net; 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:221637 Archived-At: --=-=-= 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. --=-=-=--