Refactor ef-get-theme to use or over if-let

I noticed the if-let really wasn't serving much purpose.
This commit is contained in:
TEC 2024-03-10 12:10:59 +08:00
parent dfb8eac3d9
commit 6ec666c48f
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
1 changed files with 17 additions and 18 deletions

View File

@ -465,24 +465,23 @@ Unless NOPUT is non-nil, the preset will be added to `engrave-faces-themes'.
The theme t is treated as shorthand for the current theme."
(when (eq theme t)
(setq theme (car custom-enabled-themes)))
(if-let ((theme-preset (alist-get theme engrave-faces-themes)))
theme-preset
(if (or (eq theme (car custom-enabled-themes))
(memq theme (custom-available-themes)))
(let ((spec
(if (eq theme (car custom-enabled-themes))
(engrave-faces-generate-preset)
(let ((old-theme (car custom-enabled-themes))
spec)
(load-theme theme t)
(setq spec (engrave-faces-generate-preset))
(load-theme old-theme t)
(redraw-display)
spec))))
(unless noput
(push (cons theme spec) engrave-faces-themes))
spec)
(user-error "Theme `%s' is not found in `engrave-faces-current-preset-style' or availible Emacs themes" theme))))
(or (alist-get theme engrave-faces-themes)
(if (or (eq theme (car custom-enabled-themes))
(memq theme (custom-available-themes)))
(let ((spec
(if (eq theme (car custom-enabled-themes))
(engrave-faces-generate-preset)
(let ((old-theme (car custom-enabled-themes))
spec)
(load-theme theme t)
(setq spec (engrave-faces-generate-preset))
(load-theme old-theme t)
(redraw-display)
spec))))
(unless noput
(push (cons theme spec) engrave-faces-themes))
spec)
(user-error "Theme `%s' is not found in `engrave-faces-current-preset-style' or availible Emacs themes" theme))))
(defun engrave-faces-use-theme (&optional theme insert-def)
"Select a THEME an apply it as the current engraved preset style.