From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Protesilaos Stavrou Newsgroups: gmane.emacs.bugs Subject: bug#45068: Patch for Modus themes 1.1.1? Date: Sat, 27 Feb 2021 04:35:49 +0200 Message-ID: <87tupyw83e.fsf@protesilaos.com> References: <87im9fgm27.fsf@protesilaos.com> <87zh2ozer4.fsf@tcd.ie> <87ft4edret.fsf@protesilaos.com> <87zh2ldgtf.fsf@protesilaos.com> <87k0toof83.fsf@mail.linkov.net> <83wnxo1mcr.fsf@gnu.org> <83v9d81khh.fsf@gnu.org> <83mtyk1hq3.fsf@gnu.org> <87czzgbapt.fsf@protesilaos.com> <83lfe4192f.fsf@gnu.org> <83im9814oh.fsf@gnu.org> <87sg6po0yd.fsf_-_@protesilaos.com> <83czxt2fpd.fsf@gnu.org> <87h7m0n0em.fsf@protesilaos.com> <83v9agryuz.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11390"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 45068@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 27 03:36:23 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lFpSx-0002qw-Ar for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 27 Feb 2021 03:36:23 +0100 Original-Received: from localhost ([::1]:45326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lFpSv-0007vD-Ta for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 26 Feb 2021 21:36:21 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55296) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lFpSj-0007v2-19 for bug-gnu-emacs@gnu.org; Fri, 26 Feb 2021 21:36:09 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59594) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lFpSc-0007eG-HG for bug-gnu-emacs@gnu.org; Fri, 26 Feb 2021 21:36:05 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lFpSc-0005OJ-EW for bug-gnu-emacs@gnu.org; Fri, 26 Feb 2021 21:36:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Protesilaos Stavrou Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 27 Feb 2021 02:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45068 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 45068-submit@debbugs.gnu.org id=B45068.161439336120716 (code B ref 45068); Sat, 27 Feb 2021 02:36:02 +0000 Original-Received: (at 45068) by debbugs.gnu.org; 27 Feb 2021 02:36:01 +0000 Original-Received: from localhost ([127.0.0.1]:42907 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lFpSb-0005O4-1j for submit@debbugs.gnu.org; Fri, 26 Feb 2021 21:36:01 -0500 Original-Received: from relay1-d.mail.gandi.net ([217.70.183.193]:47711) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lFpSZ-0005Np-7J for 45068@debbugs.gnu.org; Fri, 26 Feb 2021 21:35:59 -0500 X-Originating-IP: 94.46.225.161 Original-Received: from kronos (unknown [94.46.225.161]) (Authenticated sender: public@protesilaos.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 153B2240007; Sat, 27 Feb 2021 02:35:51 +0000 (UTC) In-Reply-To: <83v9agryuz.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 25 Feb 2021 16:44:20 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:200899 Archived-At: On 2021-02-25, 16:44 +0200, Eli Zaretskii wrote: >> From: Protesilaos Stavrou >> 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