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
View this message in rfc822 format
On 2021-02-25, 16:44 +0200, Eli Zaretskii <eliz <at> gnu.org> wrote:
>> From: Protesilaos Stavrou <info <at> protesilaos.com>
>> Cc: stefankangas <at> gmail.com, contovob <at> tcd.ie, 45068 <at> debbugs.gnu.org,
>> juri <at> linkov.net
>> Date: Thu, 25 Feb 2021 08:09:53 +0200
>>
>> Can you please outline what are the requirements and general
>> functionality of such a 'require-theme' function? I wish to give it a
>> try, though I can only do so in Elisp, whereas 'require' is in C...
>
> A simple implementation that checks whether a theme is already loaded,
> and if not, looks it up in a suitable list of directories and loads
> when found. The main part is to make sure themes are looked up in the
> directories where we expect them to be, as opposed to load-path, which
> is where 'require' looks for files to load. A Lisp implementation
> should be fine, I think.
>
> Let me know if you need further clarifications.
Hello Eli,
This is what I could come up with. It is not what you stipulated, as it
only accounts for the default themes' directory instead of checking the
'custom-theme-load-path'.
;; To be added to custom.el
(defun require-theme-base (base)
"Load BASE theme file.
BASE is a library that contains forms which are required by a
theme declared with `deftheme'. It is located in the same
directory as the built-in themes."
(let* ((themes-dir (expand-file-name "themes" data-directory))
(themes (directory-files themes-dir nil "\\.el\\'"))
files)
(dolist (file themes)
(unless (string-match-p "-theme\\.el\\'" file)
(push file files)))
(setq files (mapcar #'file-name-sans-extension files))
(if (and (member (format "%s" base) files)
(not (custom-theme-p base)))
(unless (featurep base)
(load-file (expand-file-name (format "%s.el" base) themes-dir)))
(error "`%s' is not a valid theme basis" base))))
I added that function to custom.el and placed the current version of my
files at etc/themes:
- modus-themes.el (the "base" file)
- modus-operandi-theme.el
- modus-vivendi-theme.el
The latter two are tweaked to use (require-theme-base 'modus-themes)
instead of (require 'modus-themes).
Compiled and tested on emacs -Q.
All theme loading seems to be working as expected. Though I understand
that the function is not up to standard for a formal patch.
--
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.