From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.bugs Subject: bug#30757: Better manipulation (suppressing, examining type) of warnings from *Warnings* buffer Date: Fri, 09 Mar 2018 16:53:26 +0100 Message-ID: <873719kzyh.fsf@gmail.com> References: <877eql1ld0.fsf@gmail.com> <871sgtnxth.fsf@gmail.com> <87woylminv.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1520610738 4952 195.159.176.226 (9 Mar 2018 15:52:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 9 Mar 2018 15:52:18 +0000 (UTC) Cc: 30757@debbugs.gnu.org To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Mar 09 16:52:13 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1euKJY-0001At-JC for geb-bug-gnu-emacs@m.gmane.org; Fri, 09 Mar 2018 16:52:12 +0100 Original-Received: from localhost ([::1]:46123 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1euKLb-0003Tl-EF for geb-bug-gnu-emacs@m.gmane.org; Fri, 09 Mar 2018 10:54:19 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54839) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1euKLQ-0003SD-5J for bug-gnu-emacs@gnu.org; Fri, 09 Mar 2018 10:54:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1euKLK-0000v3-7G for bug-gnu-emacs@gnu.org; Fri, 09 Mar 2018 10:54:08 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44809) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1euKLK-0000ur-0d for bug-gnu-emacs@gnu.org; Fri, 09 Mar 2018 10:54:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1euKLJ-0001jj-Qt for bug-gnu-emacs@gnu.org; Fri, 09 Mar 2018 10:54:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Robert Pluim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 09 Mar 2018 15:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30757 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 30757-submit@debbugs.gnu.org id=B30757.15206108166640 (code B ref 30757); Fri, 09 Mar 2018 15:54:01 +0000 Original-Received: (at 30757) by debbugs.gnu.org; 9 Mar 2018 15:53:36 +0000 Original-Received: from localhost ([127.0.0.1]:52706 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1euKKt-0001j2-Qi for submit@debbugs.gnu.org; Fri, 09 Mar 2018 10:53:36 -0500 Original-Received: from mail-wm0-f50.google.com ([74.125.82.50]:55054) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1euKKr-0001im-H5 for 30757@debbugs.gnu.org; Fri, 09 Mar 2018 10:53:33 -0500 Original-Received: by mail-wm0-f50.google.com with SMTP id z81so4728268wmb.4 for <30757@debbugs.gnu.org>; Fri, 09 Mar 2018 07:53:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:mail-copies-to:gmane-reply-to-list :date:in-reply-to:message-id:mime-version; bh=2R7uFR9WJSuQ9cdv+iqU84EoWnHOhqRoydhNLhZuHZ4=; b=CtUGtycoSvfZWugN4DJoWrZmVssbpQFTVXJ4vml5Y1hfhDZAXkjvuZ+lo7284p4+es T5XsuoTiGNLTVITxB5G1nGGeDmOgm3XnEWdLEDDxVoLmH0kQ1oAF+OSVwB2QIt9eyLe7 Oek9K2aVKFDeh9e62jQ9Iug/FzWOr0nB3ygBGlAOAnIhPBKWVvPGa41/84wWicTC936C 9VuGc1vtPhfdtjIqT56mYFATjd7ag7FJAes4hwabiuosE1x14LzQP6ShIdW5nT6m/Uvz VUUo2L2KX/REtBR6eiLS3pIscu71bAT93b8Gxm2F12vnizBnddEs4ysVczFIEewKlSCb nRsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:mail-copies-to :gmane-reply-to-list:date:in-reply-to:message-id:mime-version; bh=2R7uFR9WJSuQ9cdv+iqU84EoWnHOhqRoydhNLhZuHZ4=; b=shqI963NNrIS+3Rz0aQUVYZS9dthnwGY04L5DE9wfLEIRjH5rDvT5E7sJIX3yONNd+ o2Kud8qYY2sd0cihCoU4TKS/+OnhTufDfgH3oivCPTkuFvcIjqE4HIhWz87LzbwYza4g bY2cJOWe3+vnxFVjTaPvqKImBtQPt22ZBuicySEkCPZ+81134JG5mEiRmykIG7+oEcXX ZL0W0F9dqQg94vMIzSSYlY8DSbI41s2HHJXTtwiH/facfPqlrO/Cky3Vm/4vvooguGGl xLmPgAw2DJWV2GPEW5ESV6LhG1S5RqmpRUAf/lbnAFZjGocFuwyk0zsKVYeikaUPG8vV h2Xg== X-Gm-Message-State: AElRT7GCBnbpVheJNei200tqHLKZKQltbsdKV7lJXrc8wSRvwg8ru+DV 14x4w0aZeY2nPBOEwjadADtASu4i X-Google-Smtp-Source: AG47ELsCfS6fC7h/N19Fd3uZ4H6VfhaE3eBlAIm1bv2JhC1vMBBfNsZNv8oEhR5X2Ypi3JdPB80WBg== X-Received: by 10.28.220.2 with SMTP id t2mr2620614wmg.21.1520610807446; Fri, 09 Mar 2018 07:53:27 -0800 (PST) Original-Received: from rpluim-ubuntu ([149.5.228.1]) by smtp.gmail.com with ESMTPSA id v23sm1406022wmc.22.2018.03.09.07.53.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Mar 2018 07:53:26 -0800 (PST) Mail-Copies-To: never Gmane-Reply-To-List: yes In-Reply-To: (Noam Postavsky's message of "Fri, 9 Mar 2018 09:53:58 -0500") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:144076 Archived-At: --=-=-= Content-Type: text/plain Noam Postavsky writes: > Ah, yes, something using customize was more what I had in mind. > > Also, potentially reusing the Warning(foo) prefix for the button might > save some space, the different types of suppression could accessed by > different keybindings/mouse clicks (maybe that conflicts with the > "easy to use" goal, though, not sure). Here's what I've got so far. Suggestions welcome for wording, style changes, etc. It works fine for me, but I have warning-suppress-types and warning-suppress-log-types set to nil, so it might well fail for people who have already set those manually. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Show-log-suppression-buttons-in-display-warning-buff.patch >From 4db1f77e5d802531561918cd08e08d51447a84ec Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Fri, 9 Mar 2018 16:41:36 +0100 Subject: [PATCH] Show log suppression buttons in display-warning buffer * lisp/emacs-lisp/warnings.el (warning-suppress-warning): Define button. (warning-suppress-action): New function. (warning-suppress-log-warning): Define button. (warning-suppress-log-action): New function. (display-warning): Show buttons to allow permanent modification of warning-suppress-types and warning-suppress-log-types per warning. * etc/NEWS: Describe 'display-warning' change. --- etc/NEWS | 6 ++++++ lisp/emacs-lisp/warnings.el | 26 +++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/etc/NEWS b/etc/NEWS index 14926ba2e3..134b79e60e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -71,6 +71,12 @@ moved to the early init file (see above). * Changes in Emacs 27.1 ++++ +** Warning types can now be disabled from the warning buffer. +For each warning 'display-warning' now adds buttons to the buffer it +uses to allow permanent suppression of the warning popup or of the +warning itself. + --- ** The new option 'tooltip-resize-echo-area' avoids truncating tooltip text on GUI frames when tooltips are displayed in the echo area. Instead, diff --git a/lisp/emacs-lisp/warnings.el b/lisp/emacs-lisp/warnings.el index 489611d4d1..23f7e33af8 100644 --- a/lisp/emacs-lisp/warnings.el +++ b/lisp/emacs-lisp/warnings.el @@ -197,6 +197,21 @@ warning-suppress-p ;; we return t. some-match)) +(define-button-type 'warning-suppress-warning + 'action #'warning-suppress-action + 'help-echo "mouse-2, RET: Permanently disable popping up this warning") +(defun warning-suppress-action (button) + (customize-save-variable 'warning-suppress-types + (cons (list (button-get button 'warning-type)) + warning-suppress-types))) +(define-button-type 'warning-suppress-log-warning + 'action #'warning-suppress-log-action + 'help-echo "mouse-2, RET: Never generate this warning") +(defun warning-suppress-log-action (button) + (customize-save-variable 'warning-suppress-log-types + (cons (list (button-get button 'warning-type)) + warning-suppress-types))) + ;;;###autoload (defun display-warning (type message &optional level buffer-name) "Display a warning message, MESSAGE. @@ -223,7 +238,12 @@ display-warning See the `warnings' custom group for user customization features. See also `warning-series', `warning-prefix-function' and -`warning-fill-prefix' for additional programming features." +`warning-fill-prefix' for additional programming features. + +This will also display buttons allowing the user to permanently +disable popup of the warning or disable the warning entirely by +setting `warning-suppress-types' or `warning-suppress-log-types' +on their behalf." (if (not (or after-init-time noninteractive (daemonp))) ;; Ensure warnings that happen early in the startup sequence ;; are visible when startup completes (bug#20792). @@ -264,6 +284,10 @@ display-warning (insert (format (nth 1 level-info) (format warning-type-format typename)) message) + (insert " ") + (insert-button "Disable popup" 'type 'warning-suppress-warning 'warning-type type) + (insert " ") + (insert-button "Never generate" 'type 'warning-suppress-log-warning 'warning-type type) (newline) (when (and warning-fill-prefix (not (string-match "\n" message))) (let ((fill-prefix warning-fill-prefix) -- 2.16.1.72.g5be1f00a9 --=-=-=--