Subject: bug#30757: Better manipulation (suppressing, examining type) of warnings from *Warnings* buffer

From: Robert Pluim <[email-masked]>
Date: Fri, 09 Mar 2018 15:11:22 +0100

Noam Postavsky <[email-masked]> writes:

> Severity: wishlist
>
> It would be nice if warnings in the *Warnings* buffer came with some
> kind of button to let the user add the relevant value to
> warning-suppress-types or warning-suppress-log-types.

Adjust strings according to your personal preference. The button names
are a tad verbose as well :-)

diff --git a/lisp/emacs-lisp/warnings.el b/lisp/emacs-lisp/warnings.el
index 489611d4d1..0e31511287 100644
--- a/lisp/emacs-lisp/warnings.el
+++ b/lisp/emacs-lisp/warnings.el
@@ -197,6 +197,18 @@ warning-suppress-p
     ;; we return t.
     some-match))
 
+
+(define-button-type 'warning-suppress-warning
+  'action #'warning-suppress-action
+  'help-echo "mouse-2, RET: Suppress showing this warning")
+(defun warning-suppress-action (button)
+  (add-to-list 'warning-suppress-types (list (button-get button 'warning-type))))
+(define-button-type 'warning-suppress-log-warning
+  'action #'warning-suppress-log-action
+  'help-echo "mouse-2, RET: Never log this warning")
+(defun warning-suppress-log-action (button)
+  (add-to-list 'warning-suppress-log-types (list (button-get button 'warning-type))))
+
 ;;;###autoload
 (defun display-warning (type message &optional level buffer-name)
   "Display a warning message, MESSAGE.
@@ -264,6 +276,10 @@ display-warning
 	      (insert (format (nth 1 level-info)
 			      (format warning-type-format typename))
 		      message)
+              (insert " ")
+              (insert-button "Suppress" 'type 'warning-suppress-warning 'warning-type type)
+              (insert " ")
+              (insert-button "Never Log" '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)