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] 28.0.50; Update Modus themes 1.0.2 (backward-incompatible) Date: Sun, 28 Feb 2021 16:13:26 +0200 Message-ID: <87zgzney08.fsf@protesilaos.com> References: <87im9fgm27.fsf@protesilaos.com> <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> <87tupyw83e.fsf@protesilaos.com> <83zgzqncxx.fsf@gnu.org> <874khwn1qf.fsf@protesilaos.com> <603b8171.1c69fb81.aa664.7f40@mx.google.com> <87mtvoxsvs.fsf@protesilaos.com> <87lfb8l2wr.fsf@tcd.ie> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36990"; 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, Mauro Aranda To: "Basil L. Contovounesios" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 01 15:43:31 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 1lGjli-0009VP-OK for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 01 Mar 2021 15:43:30 +0100 Original-Received: from localhost ([::1]:34556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lGjlh-0004jU-Qg for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 01 Mar 2021 09:43:29 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46550) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGjlH-0004Ic-4a for bug-gnu-emacs@gnu.org; Mon, 01 Mar 2021 09:43:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37065) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lGjlG-0004vu-Di for bug-gnu-emacs@gnu.org; Mon, 01 Mar 2021 09:43:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lGjlG-0003HB-AU for bug-gnu-emacs@gnu.org; Mon, 01 Mar 2021 09:43: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: Mon, 01 Mar 2021 14:43: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.161460976612571 (code B ref 45068); Mon, 01 Mar 2021 14:43:02 +0000 Original-Received: (at 45068) by debbugs.gnu.org; 1 Mar 2021 14:42:46 +0000 Original-Received: from localhost ([127.0.0.1]:48611 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lGjl0-0003Gh-GA for submit@debbugs.gnu.org; Mon, 01 Mar 2021 09:42:46 -0500 Original-Received: from relay12.mail.gandi.net ([217.70.178.232]:36199) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lGjkv-0003GQ-Gu for 45068@debbugs.gnu.org; Mon, 01 Mar 2021 09:42:45 -0500 Original-Received: from kronos (unknown [94.46.225.161]) (Authenticated sender: public@protesilaos.com) by relay12.mail.gandi.net (Postfix) with ESMTPSA id A9D0A200004; Mon, 1 Mar 2021 14:42:34 +0000 (UTC) In-Reply-To: <87lfb8l2wr.fsf@tcd.ie> (Basil L. Contovounesios's message of "Sun, 28 Feb 2021 13:47:48 +0000") 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:201095 Archived-At: [ 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" wrote: > Thanks, just some nits from me. > > Protesilaos Stavrou 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