[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#30757: Better manipulation (suppressing, examining type) of warnings

From: Robert Pluim
Subject: bug#30757: Better manipulation (suppressing, examining type) of warnings from *Warnings* buffer
Date: Fri, 09 Mar 2018 16:53:26 +0100

Noam Postavsky <address@hidden> 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.

>From 4db1f77e5d802531561918cd08e08d51447a84ec Mon Sep 17 00:00:00 2001
From: Robert Pluim <address@hidden>
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.
+(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)))
 (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))
+              (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)
              (when (and warning-fill-prefix (not (string-match "\n" message)))
                (let ((fill-prefix warning-fill-prefix)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]