[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 16:13:26 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
[ 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@tcd.ie> wrote:
> Thanks, just some nits from me.
>
> Protesilaos Stavrou <info@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
- bug#45068: [PATCH] Modus themes 1.2.0, (continued)
- bug#45068: [PATCH] Modus themes 1.2.0, Gregory Heytings, 2021/03/05
- bug#45068: [PATCH] Modus themes 1.2.0, Gregory Heytings, 2021/03/06
- bug#45068: [PATCH] Modus themes 1.2.0, Protesilaos Stavrou, 2021/03/06
- bug#45068: [PATCH] Modus themes 1.2.0, Gregory Heytings, 2021/03/06
- bug#45068: [PATCH] Modus themes 1.2.0, Protesilaos Stavrou, 2021/03/06
- bug#45068: [PATCH] 28.0.50; Update Modus themes 1.0.2 (backward-incompatible), Basil L. Contovounesios, 2021/03/04
bug#45068: [PATCH] 28.0.50; Update Modus themes 1.0.2 (backward-incompatible), Protesilaos Stavrou, 2021/03/01
bug#45068: [PATCH] 28.0.50; Update Modus themes 1.0.2 (backward-incompatible),
Protesilaos Stavrou <=
bug#45068: [PATCH] 28.0.50; Update Modus themes 1.0.2 (backward-incompatible), Protesilaos Stavrou, 2021/03/01