GNU bug report logs -
#45068
[PATCH] 28.0.50; Update Modus themes 1.0.2 (backward-incompatible)
Previous Next
Reported by: Protesilaos Stavrou <info <at> protesilaos.com>
Date: Sun, 6 Dec 2020 12:25:02 UTC
Severity: normal
Tags: patch
Fixed in version 28.1
Done: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Bug is archived. No further changes may be made.
Full log
Message #125 received at 45068 <at> debbugs.gnu.org (full text, mbox):
[ resending because it was lost, as Lars explained on emacs-devel:
"Discarded messages to the bug tracker yesterday" ]
On 2021-02-28, 13:47 +0000, "Basil L. Contovounesios" <contovob <at> tcd.ie> wrote:
> Thanks, just some nits from me.
>
> Protesilaos Stavrou <info <at> protesilaos.com> writes:
>
>> With optional DIRECTORIES as a list of filesystem paths, search
>> for THEME file in those locations instead and load it, if
>> present."
>
> GNU terminology distinguishes between "file names" and "paths", where
> the latter is a list of directories to search.
> See (info "(standards) GNU Manuals").
>
> So I suggest calling this argument "path" like that of locate-file.
>
>> (cond
>> ((member theme (member theme (custom-available-themes)))
>
> Duplicate member, and this can be memq instead, right?
>
>> (load-theme theme))
>> ((let* ((theme-dirs (custom-theme--load-path))
>> (custom-dirs (when (and directories (listp directories))
>> directories))
>
> AKA (and (consp directories) directories), but see below. I don't think
> we need to cater for callers passing atoms instead of lists.
>
>> (dirs (or custom-dirs theme-dirs))
>
> I think you could just say (or directories (custom-theme--load-path)).
>
>> (file (locate-file (symbol-name theme) dirs '(".el" ".elc"))))
>> (when (and file (not (featurep theme)))
>
> Maybe featurep should be checked before calling locate-file?
>
>> (load-file file))))))
Thank you Basil!
The duplicate 'member' was a mistake, while Mauro also suggested 'memq'.
If I understood your input correctly, the function should become:
(defun require-theme (theme &optional paths)
"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 PATHS as a list of filesystem paths, search for THEME
file in those locations instead and load it, if present."
(cond
((memq theme (custom-available-themes))
(load-theme theme))
((let* ((dirs (or paths (custom-theme--load-path)))
(file (unless (featurep theme)
(locate-file (symbol-name theme) dirs '(".el" ".elc")))))
(when file
(require theme file))))))
[ Note that the 'require' call was part of the parallel thread with my
reply to Mauro's feedback. Or keep 'load-file' for that? ]
--
Protesilaos Stavrou
protesilaos.com
This bug report was last modified 4 years and 135 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.