bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#45068: Patch for Modus themes 1.1.1?


From: Protesilaos Stavrou
Subject: bug#45068: Patch for Modus themes 1.1.1?
Date: Sat, 27 Feb 2021 04:35:49 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

On 2021-02-25, 16:44 +0200, Eli Zaretskii <eliz@gnu.org> wrote:

>> From: Protesilaos Stavrou <info@protesilaos.com>
>> Cc: stefankangas@gmail.com,  contovob@tcd.ie,  45068@debbugs.gnu.org,
>>   juri@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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]