[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#45068: [PATCH] 28.0.50; Update Modus themes 1.0.2 (backward-incompat
From: |
Protesilaos Stavrou |
Subject: |
bug#45068: [PATCH] 28.0.50; Update Modus themes 1.0.2 (backward-incompatible) |
Date: |
Sun, 28 Feb 2021 14:45:59 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
On 2021-02-28, 08:41 -0300, Mauro Aranda <maurooaranda@gmail.com> wrote:
> Hi Protesilaos,
Hello Mauro and thank you for the valuable feedback!
I have written the function anew based on your suggestions. I also
added a featurep check to ensure that the same file is not loaded
repeatedly. Furthermore, I streamlined the type of THEME to always be a
symbol.
(defun require-theme (theme &optional directories)
"Load THEME stored in `custom-theme-load-path'.
THEME is a symbol that corresponds to the file name without its file
type extension. That is assumed to be either '.el' or '.elc'.
If THEME names an element of `custom-available-themes', load it asking
for confirmation if it is not considered safe by `custom-safe-themes'.
Otherwise load the file, if present. In the latter case, the file is
intended to work as the basis of a theme declared with `deftheme'.
With optional DIRECTORIES as a list of filesystem paths, search
for THEME file in those locations instead and load it, if
present."
(cond
((member theme (member theme (custom-available-themes)))
(load-theme theme))
((let* ((theme-dirs (custom-theme--load-path))
(custom-dirs (when (and directories (listp directories))
directories))
(dirs (or custom-dirs theme-dirs))
(file (locate-file (symbol-name theme) dirs '(".el" ".elc"))))
(when (and file (not (featurep theme)))
(load-file file))))))
Please feel welcome to suggest any further changes/refinements. This is
not my area of expertise, so apologies for taking so long to get it
right.
--
Protesilaos Stavrou
protesilaos.com