aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-04-26 18:01:30 -0500
committerCraig Jennings <c@cjennings.net>2026-04-26 18:01:30 -0500
commitc5e5e1dfb808efa8724a993771e5258e728f83d1 (patch)
treecd870fce078071d366920c19e7529b7dce8e18c0
parent8f3c770e062a9aefec17f6b5f4f0a5ed927ac603 (diff)
downloademacs-wttrin-c5e5e1dfb808efa8724a993771e5258e728f83d1.tar.gz
emacs-wttrin-c5e5e1dfb808efa8724a993771e5258e728f83d1.zip
fix: omit :foreground from emoji icon face when no color provided
The font branch of wttrin--make-emoji-icon built its face plist with `:foreground foreground` even when foreground was nil, producing a literal `(:family ... :height 1.0 :foreground nil)`. The mode-line redisplays many times per second, and Emacs validates faces on every redisplay. A single fresh-cache state produced hundreds of "Invalid face attribute :foreground nil" warnings in *Messages*. The bug's been live since 2026-02-21 (b74b98f). The 130bbc07 helper extraction kept it in place. Switch to backquote splicing so the :foreground key is included only when foreground is non-nil. Behavior is identical on the colored path. On the nil path the emoji renders with the default mode-line color, the same visible result as before, without the warning flood.
-rw-r--r--wttrin.el11
1 files changed, 7 insertions, 4 deletions
diff --git a/wttrin.el b/wttrin.el
index d09a64a..0f84f7a 100644
--- a/wttrin.el
+++ b/wttrin.el
@@ -597,12 +597,15 @@ user's original casing so tooltips display what the user expects."
(defun wttrin--make-emoji-icon (emoji &optional foreground)
"Create EMOJI string with optional font face and FOREGROUND color.
-Uses `wttrin-mode-line-emoji-font' when configured."
+Uses `wttrin-mode-line-emoji-font' when configured.
+Omits `:foreground' from the face plist when FOREGROUND is nil — a literal
+`:foreground nil' entry triggers \"Invalid face attribute\" warnings on every
+redisplay."
(if wttrin-mode-line-emoji-font
(propertize emoji
- 'face (list :family wttrin-mode-line-emoji-font
- :height 1.0
- :foreground foreground))
+ 'face `(:family ,wttrin-mode-line-emoji-font
+ :height 1.0
+ ,@(when foreground (list :foreground foreground))))
(if foreground
(propertize emoji 'face (list :foreground foreground))
emoji)))