fancy-splash: handle named (non-hex) colours

This commit is contained in:
TEC 2022-11-08 23:29:53 +08:00
parent 1a101bd5e3
commit 14995a15c9
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
1 changed files with 11 additions and 4 deletions

View File

@ -2195,11 +2195,18 @@ and the current theme."
(warn "Warning! fancy splash template: neither $height nor height=100 not found in %s" template)))
(dolist (substitution fancy-splash-template-colours)
(goto-char (point-min))
(let ((replacement
(face-attribute (plist-get (cdr substitution) :face)
:foreground nil 'default)))
(let* ((replacement-colour
(face-attribute (plist-get (cdr substitution) :face)
(or (plist-get (cdr substitution) :attr) :foreground)
nil 'default))
(replacement-hex
(if (string-prefix-p "#" replacement-colour)
replacement-colour
(apply 'format "#%02x%02x%02x"
(mapcar (lambda (c) (ash c -8))
(color-values replacement-colour))))))
(while (search-forward (car substitution) nil t)
(replace-match replacement nil nil))))
(replace-match replacement-hex nil nil))))
(unless (file-exists-p fancy-splash-cache-dir)
(make-directory fancy-splash-cache-dir t))
(let ((inhibit-message t))