Subject: bug#61413: [PATCH] Make warnings show a "warning" emoji instead of a stop-sign

From: Kévin Le Gouguec <[email-masked]>
Date: Sun, 23 Feb 2025 17:09:24 +0100

Kévin Le Gouguec <[email-masked]> writes:

> Back to the topic of the warnings-suppress icon representations: FWIW, I
> toyed with status/dialog-error-symbolic.svg from adwaita-icon-theme, but
> could not land on a result I found perfectly harmonious.

Figured that for all the button.el help-echo noodling, it would not hurt
to give a shot to the most-requested suggestions in this report: show a
warning sign *for presentation only*, and use an explicit plain text
button for suppression.

Attaching the result (patch & screenshot).  OT1H it feels like there is
room for further refinement¹, OTOH I prefer to send that iteration first
before building castles in the air.

¹ Integration with warning-prefix-function, varying faces with warning
levels, figuring out what the deal is with invoking 'newline instead of
inserting "\n" directly, using define-button-type & insert-button which
I just learned about…

>From 0e4afa554f4cffd3b96ea5956ff2853b0c4e2778 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= <[email-masked]>
Date: Sun, 23 Feb 2025 16:40:19 +0100
Subject: [PATCH] Use plain text for warning supression button

As discussed in bug#61413, even if we fix button.el stripping
the icon's help-echo property, the no-entry sign remains
unintuitive.

* etc/images/README: Record new image provenance.
* etc/images/warning.svg: New image for prefixing warnings.
* lisp/emacs-lisp/warnings.el (warning): New icon, respecting
the 'warning face.
(display-warning): Use the new icon; move suppression button
after warning text, and make it a plain text button.
---
 etc/images/README           |   9 +++++----
 etc/images/warning.pbm      | Bin 0 -> 41 bytes
 etc/images/warning.svg      |   4 ++++
 lisp/emacs-lisp/warnings.el |  32 +++++++++++++++++++++++++-------
 4 files changed, 34 insertions(+), 11 deletions(-)
 create mode 100644 etc/images/warning.pbm
 create mode 100644 etc/images/warning.svg

diff --git a/etc/images/README b/etc/images/README
index d3f442a3b24..ebdb37fd3be 100644
--- a/etc/images/README
+++ b/etc/images/README
@@ -137,8 +137,9 @@ Emacs images and their source in the Adwaita/symbolic directory:
   left.svg                  ui/pan-start-symbolic.svg
   right.svg                 ui/pan-end-symbolic.svg
   up.svg                    ui/pan-up-symbolic.svg
-  conceal.svg               actions/view-conceal-symbolic.svg
-  reveal.svg                actions/view-reveal-symbolic.svg
+  conceal.svg(*)            actions/view-conceal-symbolic.svg
+  reveal.svg(*)             actions/view-reveal-symbolic.svg
+  warning.svg(*)            status/dialog-warning-symbolic.svg
 
-conceal.pbm and reveal.pbm are generated from the respective *.svg
-files, using the ImageMagick converter tool.
+  (*) *.pbm files were generated from the respective *.svg files, using
+  the ImageMagick converter tool.
diff --git a/etc/images/warning.pbm b/etc/images/warning.pbm
new file mode 100644
index 0000000000000000000000000000000000000000..7bbb5dd30a997698ee9360e9732fee97b3c23605
GIT binary patch
literal 41
xcmWGA;W9K+Ff`+0Y+ydXe1QD{TLNDJUx8eOU4>mu{lB`pfA#<W|NqCp008}T56%Dp

literal 0
HcmV?d00001

diff --git a/etc/images/warning.svg b/etc/images/warning.svg
new file mode 100644
index 00000000000..3bfbba00714
--- /dev/null
+++ b/etc/images/warning.svg
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
+    <path d="m 7.90625 0.09375 c -0.527344 -0.0273438 -1.039062 0.28125 -1.4375 0.96875 l -6.25 11.59375 c -0.535156 0.964844 0.046875 2.34375 1.09375 2.34375 h 13.15625 c 0.980469 0 1.902344 -1.160156 1.21875 -2.34375 l -6.3125 -11.53125 c -0.398438 -0.644531 -0.941406 -1.003906 -1.46875 -1.03125 z m 1.09375 3.90625 v 5 c 0.007812 0.527344 -0.472656 1 -1 1 s -1.007812 -0.472656 -1 -1 v -5 z m -1 7 c 0.550781 0 1 0.449219 1 1 s -0.449219 1 -1 1 s -1 -0.449219 -1 -1 s 0.449219 -1 1 -1 z m 0 0"/>
+</svg>
diff --git a/lisp/emacs-lisp/warnings.el b/lisp/emacs-lisp/warnings.el
index 8a5c73ebd3a..a08ec96b49b 100644
--- a/lisp/emacs-lisp/warnings.el
+++ b/lisp/emacs-lisp/warnings.el
@@ -212,6 +212,15 @@ warning-suppress-p
     ;; we return t.
     some-match))
 
+(define-icon warning nil
+  '((image "warning.svg" "warning.pbm" :face warning)
+    (emoji "⚠️")
+    (symbol "⚠" :face warning)
+    (text "WARNING" :face warning))
+  "Warning indicator."
+  :version "31.1")
+
+;; Unused in-tree; see bug#61413.  Kept for backward compatibility.
 (define-icon warnings-suppress button
   `((emoji "⛔")
     ;; Many MS-Windows console fonts don't have good glyphs for U+25A0.
@@ -312,22 +321,31 @@ display-warning
 		    (prog1 (point-marker)
 		      (unless (eq warning-series t)
 			(funcall warning-series)))))
-	    (let ((inhibit-read-only t))
+	    (let ((inhibit-read-only t)
+                  ;; Don't output buttons or icons when doing batch
+                  ;; compilation and similar.
+                  (decorate (not (or noninteractive
+                                     (eq type 'bytecomp)))))
 	      (unless (bolp)
 		(funcall newline))
 	      (setq start (point))
-              ;; Don't output the button when doing batch compilation
-              ;; and similar.
-              (unless (or noninteractive (eq type 'bytecomp))
-                (insert (buttonize (icon-string 'warnings-suppress)
-                                   #'warnings-suppress type)
-                        " "))
+              (when decorate
+                (insert (icon-string 'warning) " "))
 	      (if warning-prefix-function
 		  (setq level-info (funcall warning-prefix-function
 					    level level-info)))
 	      (insert (format (nth 1 level-info)
 			      (format warning-type-format typename))
 		      message)
+              (when decorate
+                (insert
+                 " "
+                 (buttonize
+                  "(suppress)" #'warnings-suppress type
+                  (format "Click to suppress warnings of type `%s'" type))
+                 ;; FIXME: add un-propertized space to prevent
+                 ;; buttonizing next newline:
+                 " "))
               (funcall newline)
 	      (when (and warning-fill-prefix
                          (not (string-search "\n" message))
-- 
2.48.1