From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#57639: [PATCH] Add new command 'toggle-theme' Date: Thu, 13 Oct 2022 08:50:34 +0000 Message-ID: <875ygohztx.fsf@posteo.net> References: <875yhzmz25.fsf@posteo.net> <87mtatagzv.fsf@gnus.org> <87edw5n2zm.fsf@posteo.net> <87o7v97zy2.fsf@gnus.org> <87bkr9newj.fsf@posteo.net> <871qs57yai.fsf@gnus.org> <87y1udlzlt.fsf@posteo.net> <87o7v953uf.fsf@gnus.org> <87tu50nca7.fsf@posteo.net> <87a6652lyb.fsf@posteo.net> <875ygtqdho.fsf@gnus.org> <87wn99114w.fsf@posteo.net> <87wn98nlhq.fsf@gnus.org> <87lepo9c1e.fsf@posteo.net> <87r0zfkxzx.fsf@gnus.org> <87pmeyg24x.fsf@posteo.net> <87edvef8nc.fsf@gnus.org> <871qre2l63.fsf@posteo.net> <875ygqf7pc.fsf@gnus.org> <87r0ze15rt.fsf@posteo.net> <871qref5mq.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24637"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 57639@debbugs.gnu.org, Protesilaos Stavrou To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 13 11:38:42 2022 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 1oiufq-0006En-3J for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 13 Oct 2022 11:38:42 +0200 Original-Received: from localhost ([::1]:52256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiufo-0003u7-J8 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 13 Oct 2022 05:38:40 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oitvi-0003Hm-F1 for bug-gnu-emacs@gnu.org; Thu, 13 Oct 2022 04:51:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60416) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oitvi-0007t6-38 for bug-gnu-emacs@gnu.org; Thu, 13 Oct 2022 04:51:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oitvh-0001D8-Ts for bug-gnu-emacs@gnu.org; Thu, 13 Oct 2022 04:51:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 13 Oct 2022 08:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57639 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 57639-submit@debbugs.gnu.org id=B57639.16656510484631 (code B ref 57639); Thu, 13 Oct 2022 08:51:01 +0000 Original-Received: (at 57639) by debbugs.gnu.org; 13 Oct 2022 08:50:48 +0000 Original-Received: from localhost ([127.0.0.1]:59494 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oitvS-0001Cc-QL for submit@debbugs.gnu.org; Thu, 13 Oct 2022 04:50:48 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:55101) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oitvP-0001CM-Lc for 57639@debbugs.gnu.org; Thu, 13 Oct 2022 04:50:45 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id B33CB240104 for <57639@debbugs.gnu.org>; Thu, 13 Oct 2022 10:50:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1665651037; bh=qVUKTtG+mEuEoIL8KkBWchsXOlSxjTUoePMsu1bnnv8=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=JfVe0t4LU4SuVa5xh2fJQPsq/7YVkX0OY5mHxSEhZw9Hj3Tapb1IV7i+sLnu1mKTj bvPGq0Y/Wp+MV4mNr38gCdA3V5QKb4bWXLq4d+gxFIA9gIcdMmbmp2GjcHjCIXB0pK bfStHlze2C73RVz3tBlm7HFVZ39RJp7+/fcz+f1q64obUsgotf+SZz73O4uNYXzALA y8X/L8zwvTnXbsQAxLvl96pJ3SVK3dr3t34YKR00+djMB10/LcUZLqXoy9ImWkrav9 nAGlr46K3ayC8zwGflRmuFWgMXLVl+SbOpeDxDG/3Iz6JWrv8uOIyOzhrqNN4/rf3u pFLqC8BW/9hsQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Mp3Bg5vKQz6tmb; Thu, 13 Oct 2022 10:50:35 +0200 (CEST) In-Reply-To: <871qref5mq.fsf@gnus.org> (Lars Ingebrigtsen's message of "Tue, 11 Oct 2022 22:49:01 +0200") Autocrypt: addr=philipk@posteo.net; prefer-encrypt=nopreference; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB 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:245281 Archived-At: --=-=-= Content-Type: text/plain Lars Ingebrigtsen writes: > Philip Kaludercic writes: > >> Great, can you point me to the places I would have to make changes for >> this to work: >> >> add a function to loaddefs-gen that only fetched those for the >> Emacs build (it'd almost be trivial -- we just bind >> lisp-mode-autoload-regexp to ";;;###theme-autoload" and then >> point the scraping function at etc/themes). > > I think you'd basically put something like the following into > `loaddefs-generate--emacs-batch' -- > > (let ((lisp-mode-autoload-regexp > "^;;;###\\(\\(noexist\\)-\\)?\\(theme-autoload\\)")) > (loaddefs-generate > (expand-file-name "../etc/themes/" lisp-directory) > (expand-file-name "theme-loaddefs.el" lisp-directory))) > > Then you have to teach `loaddefs-generate--make-autoload' to generate > the correct forms as a result of the `deftheme' -- which should be some > `put's. OK, it looks like this worked. Just to recap, these are the proposed changes: --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Tag-themes-with-properties.patch >From 5436a1b7d1bac4d55770cd84cbef545bfdd930b3 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Sat, 17 Sep 2022 20:11:42 +0200 Subject: [PATCH] Tag themes with properties * doc/emacs/custom.texi (Custom Themes): Document 'theme-choose-variant'. * doc/lispref/customize.texi (Custom Themes): Document the new optional argument to 'deftheme'. * etc/themes/adwaita-theme.el (adwaita): Add properties. * etc/themes/deeper-blue-theme.el (deeper-blue): Add properties. * etc/themes/dichromacy-theme.el (dichromacy): Add properties. * etc/themes/light-blue-theme.el (light-blue): Add properties. * etc/themes/manoj-dark-theme.el (manoj-dark): Add properties. * etc/themes/misterioso-theme.el (misterioso): Add properties. * etc/themes/tango-dark-theme.el (tango-dark): Add properties. * etc/themes/tango-theme.el (tango): Add properties. * etc/themes/tsdh-dark-theme.el (tsdh-dark): Add properties. * etc/themes/tsdh-light-theme.el (tsdh-light): Add properties. * etc/themes/wheatgrass-theme.el (wheatgrass): Add properties. * etc/themes/whiteboard-theme.el (whiteboard): Add properties. * etc/themes/wombat-theme.el (wombat): Add properties. * etc/themes/modus-operandi-theme.el: Add properties. * etc/themes/modus-vivendi-theme.el: Add properties. * etc/themes/leuven-dark-theme.el (leuven-dark): Add properties. * etc/themes/leuven-theme.el (leuven): Add properties. * lisp/custom.el (deftheme): Allow for optional arguments to set the property list. (custom-declare-theme): Accept the same optional arguments as 'deftheme'. (theme-list-variants): Add new function. (theme-choose-variant): Add new command for switching between members of a theme family. (toggle-theme): Add an alias for 'theme-choose-variant'. (Bug#57639) * lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate--make-autoload): Handle 'defcustom's by extracting the properties. --- doc/emacs/custom.texi | 10 +++++ doc/lispref/customize.texi | 5 ++- etc/themes/adwaita-theme.el | 5 ++- etc/themes/deeper-blue-theme.el | 5 ++- etc/themes/dichromacy-theme.el | 5 ++- etc/themes/leuven-dark-theme.el | 8 +++- etc/themes/leuven-theme.el | 8 +++- etc/themes/light-blue-theme.el | 5 ++- etc/themes/manoj-dark-theme.el | 5 ++- etc/themes/misterioso-theme.el | 5 ++- etc/themes/modus-operandi-theme.el | 2 + etc/themes/modus-vivendi-theme.el | 2 + etc/themes/tango-dark-theme.el | 7 ++- etc/themes/tango-theme.el | 6 ++- etc/themes/tsdh-dark-theme.el | 6 ++- etc/themes/tsdh-light-theme.el | 6 ++- etc/themes/wheatgrass-theme.el | 5 ++- etc/themes/whiteboard-theme.el | 5 ++- etc/themes/wombat-theme.el | 5 ++- lisp/custom.el | 70 +++++++++++++++++++++++++++--- lisp/emacs-lisp/loaddefs-gen.el | 6 +++ 21 files changed, 156 insertions(+), 25 deletions(-) diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi index ff7ab83190..f98527bf9a 100644 --- a/doc/emacs/custom.texi +++ b/doc/emacs/custom.texi @@ -667,6 +667,16 @@ Custom Themes the @file{*Custom Themes*} buffer; or type @kbd{M-x describe-theme} anywhere in Emacs and enter the theme name. +@findex theme-choose-variant +Some themes have variants (most often just two: light and dark). You +can switch to another variant using @kbd{M-x theme-choose-variant}. +If the currently active theme has only one other variant, it will be +selected; if there are more variants, the command will prompt you +which one to switch to. + +Note that @code{theme-choose-variant} only works if a single theme +is active. + @node Creating Custom Themes @subsection Creating Custom Themes @cindex custom themes, creating diff --git a/doc/lispref/customize.texi b/doc/lispref/customize.texi index 6ba35cffff..911b6c4d75 100644 --- a/doc/lispref/customize.texi +++ b/doc/lispref/customize.texi @@ -1428,12 +1428,13 @@ Custom Themes be a call to @code{deftheme}, and the last form should be a call to @code{provide-theme}. -@defmac deftheme theme &optional doc +@defmac deftheme theme &optional doc &rest properties This macro declares @var{theme} (a symbol) as the name of a Custom theme. The optional argument @var{doc} should be a string describing the theme; this is the description shown when the user invokes the @code{describe-theme} command or types @kbd{?} in the @samp{*Custom -Themes*} buffer. +Themes*} buffer. The remaining arguments @var{properties} are used +pass a property list with theme attributes. Two special theme names are disallowed (using them causes an error): @code{user} is a dummy theme that stores the user's direct diff --git a/etc/themes/adwaita-theme.el b/etc/themes/adwaita-theme.el index ba83a0578c..6ad8405559 100644 --- a/etc/themes/adwaita-theme.el +++ b/etc/themes/adwaita-theme.el @@ -21,10 +21,13 @@ ;;; Code: +;;;###theme-autoload (deftheme adwaita "Face colors similar to the default theme of Gnome 3 (Adwaita). The colors are chosen to match Adwaita window decorations and the -default look of the Gnome 3 desktop.") +default look of the Gnome 3 desktop." + :background-mode 'light + :kind 'color-scheme) (let ((class '((class color) (min-colors 89)))) (custom-theme-set-faces diff --git a/etc/themes/deeper-blue-theme.el b/etc/themes/deeper-blue-theme.el index 8f19147f91..48ed9ba061 100644 --- a/etc/themes/deeper-blue-theme.el +++ b/etc/themes/deeper-blue-theme.el @@ -21,8 +21,11 @@ ;;; Code: +;;;###theme-autoload (deftheme deeper-blue - "Face colors using a deep blue background.") + "Face colors using a deep blue background." + :background-mode 'dark + :kind 'color-scheme) (let ((class '((class color) (min-colors 89)))) (custom-theme-set-faces diff --git a/etc/themes/dichromacy-theme.el b/etc/themes/dichromacy-theme.el index d53c075d92..fe44d520cc 100644 --- a/etc/themes/dichromacy-theme.el +++ b/etc/themes/dichromacy-theme.el @@ -21,6 +21,7 @@ ;;; Code: +;;;###theme-autoload (deftheme dichromacy "Face colors suitable for red/green color-blind users. The color palette is from B. Wong, Nature Methods 8, 441 (2011). @@ -28,7 +29,9 @@ dichromacy differentiated by individuals with protanopia or deuteranopia. Basic, Font Lock, Isearch, Gnus, Message, Flyspell, and -Ansi-Color faces are included.") +Ansi-Color faces are included." + :background-mode 'light + :kind 'color-scheme) (let ((class '((class color) (min-colors 89))) (orange "#e69f00") diff --git a/etc/themes/leuven-dark-theme.el b/etc/themes/leuven-dark-theme.el index 0e162c8bab..08978a2668 100644 --- a/etc/themes/leuven-dark-theme.el +++ b/etc/themes/leuven-dark-theme.el @@ -5,7 +5,7 @@ ;; Author: Fabrice Niessen <(concat "fniessen" at-sign "pirilampo.org")> ;; Contributor: Thibault Polge <(concat "thibault" at-sign "thb.lt")> ;; URL: https://github.com/fniessen/emacs-leuven-dark-theme -;; Version: 20220202.1126 +;; Version: 20221010.1208 ;; Keywords: color theme ;; This file is part of GNU Emacs. @@ -93,11 +93,15 @@ leuven-dark-scale-font ;;; Theme Faces. +;;;###theme-autoload (deftheme leuven-dark "Face colors with a light background. Basic, Font Lock, Isearch, Gnus, Message, Org mode, Diff, Ediff, Flyspell, Semantic, and Ansi-Color faces are included -- and much -more...") +more..." + :background-mode 'dark + :family 'leuven + :kind 'color-scheme) (let ((class '((class color) (min-colors 89))) diff --git a/etc/themes/leuven-theme.el b/etc/themes/leuven-theme.el index d9a8d5391a..e712a79adf 100644 --- a/etc/themes/leuven-theme.el +++ b/etc/themes/leuven-theme.el @@ -4,7 +4,7 @@ ;; Author: Fabrice Niessen <(concat "fniessen" at-sign "pirilampo.org")> ;; URL: https://github.com/fniessen/emacs-leuven-theme -;; Version: 20200513.1928 +;; Version: 20221010.1209 ;; Keywords: color theme ;; This file is part of GNU Emacs. @@ -74,11 +74,15 @@ leuven-scale-font ;;; Theme Faces. +;;;###theme-autoload (deftheme leuven "Face colors with a light background. Basic, Font Lock, Isearch, Gnus, Message, Org mode, Diff, Ediff, Flyspell, Semantic, and Ansi-Color faces are included -- and much -more...") +more..." + :background-mode 'light + :kind 'color-scheme + :family 'leuven) (let ((class '((class color) (min-colors 89))) diff --git a/etc/themes/light-blue-theme.el b/etc/themes/light-blue-theme.el index eeca46210c..808fcbfeb2 100644 --- a/etc/themes/light-blue-theme.el +++ b/etc/themes/light-blue-theme.el @@ -26,8 +26,11 @@ ;;; Code: +;;;###theme-autoload (deftheme light-blue - "Face colors utilizing a light blue background.") + "Face colors utilizing a light blue background." + :background-mode 'light + :kind 'color-scheme) (make-obsolete 'light-blue nil "29.1") diff --git a/etc/themes/manoj-dark-theme.el b/etc/themes/manoj-dark-theme.el index af5576386c..f9aaa97c25 100644 --- a/etc/themes/manoj-dark-theme.el +++ b/etc/themes/manoj-dark-theme.el @@ -64,10 +64,13 @@ ;;; Code: +;;;###theme-autoload (deftheme manoj-dark "Very high contrast faces with a black background. This theme avoids subtle color variations, while avoiding the -jarring angry fruit salad look to reduce eye fatigue.") +jarring angry fruit salad look to reduce eye fatigue." + :background-mode 'dark + :kind 'color-scheme) (custom-theme-set-faces 'manoj-dark diff --git a/etc/themes/misterioso-theme.el b/etc/themes/misterioso-theme.el index 55186384ad..3fd6cdb5af 100644 --- a/etc/themes/misterioso-theme.el +++ b/etc/themes/misterioso-theme.el @@ -21,8 +21,11 @@ ;;; Code: +;;;###theme-autoload (deftheme misterioso - "Predominantly blue/cyan faces on a dark cyan background.") + "Predominantly blue/cyan faces on a dark cyan background." + :background-mode 'dark + :kind 'color-scheme) (let ((class '((class color) (min-colors 89)))) diff --git a/etc/themes/modus-operandi-theme.el b/etc/themes/modus-operandi-theme.el index 6e609c0803..0f0630a6d1 100644 --- a/etc/themes/modus-operandi-theme.el +++ b/etc/themes/modus-operandi-theme.el @@ -71,4 +71,6 @@ (provide-theme 'modus-operandi)) +;;;###theme-autoload (put 'modus-operandi 'theme-properties '(:background-mode light :kind color-scheme :family modus)) + ;;; modus-operandi-theme.el ends here diff --git a/etc/themes/modus-vivendi-theme.el b/etc/themes/modus-vivendi-theme.el index 0983e26c78..02c2d9e129 100644 --- a/etc/themes/modus-vivendi-theme.el +++ b/etc/themes/modus-vivendi-theme.el @@ -71,4 +71,6 @@ (provide-theme 'modus-vivendi)) +;;;###theme-autoload (put 'modus-vivendi 'theme-properties '(:background-mode dark :kind color-scheme :family modus)) + ;;; modus-vivendi-theme.el ends here diff --git a/etc/themes/tango-dark-theme.el b/etc/themes/tango-dark-theme.el index ef00d2ac49..85995e4e99 100644 --- a/etc/themes/tango-dark-theme.el +++ b/etc/themes/tango-dark-theme.el @@ -27,10 +27,15 @@ ;;; Code: +;;;###theme-autoload (deftheme tango-dark "Face colors using the Tango palette (dark background). Basic, Font Lock, Isearch, Gnus, Message, Ediff, Flyspell, -Semantic, and Ansi-Color faces are included.") +Semantic, and Ansi-Color faces are included." + :background-mode 'dark + :kind 'color-scheme + :family 'tango) + (let ((class '((class color) (min-colors 89))) ;; Tango palette colors. diff --git a/etc/themes/tango-theme.el b/etc/themes/tango-theme.el index ecbbf03753..2ac1b42294 100644 --- a/etc/themes/tango-theme.el +++ b/etc/themes/tango-theme.el @@ -27,10 +27,14 @@ ;;; Code: +;;;###theme-autoload (deftheme tango "Face colors using the Tango palette (light background). Basic, Font Lock, Isearch, Gnus, Message, Ediff, Flyspell, -Semantic, and Ansi-Color faces are included.") +Semantic, and Ansi-Color faces are included." + :background-mode 'light + :kind 'color-scheme + :family 'tango) (let ((class '((class color) (min-colors 89))) ;; Tango palette colors. diff --git a/etc/themes/tsdh-dark-theme.el b/etc/themes/tsdh-dark-theme.el index a88ad75520..6b1e865e42 100644 --- a/etc/themes/tsdh-dark-theme.el +++ b/etc/themes/tsdh-dark-theme.el @@ -19,8 +19,12 @@ ;;; Code: +;;;###theme-autoload (deftheme tsdh-dark - "A dark theme used and created by Tassilo Horn.") + "A dark theme used and created by Tassilo Horn." + :background-mode 'dark + :kind 'color-scheme + :family 'tsdh) (custom-theme-set-faces 'tsdh-dark diff --git a/etc/themes/tsdh-light-theme.el b/etc/themes/tsdh-light-theme.el index d9d09b702b..ac964d66d6 100644 --- a/etc/themes/tsdh-light-theme.el +++ b/etc/themes/tsdh-light-theme.el @@ -19,9 +19,13 @@ ;;; Code: +;;;###theme-autoload (deftheme tsdh-light "A light Emacs theme. -Used and created by Tassilo Horn.") +Used and created by Tassilo Horn." + :background-mode 'light + :kind 'color-scheme + :family 'tsdh) (custom-theme-set-faces 'tsdh-light diff --git a/etc/themes/wheatgrass-theme.el b/etc/themes/wheatgrass-theme.el index c56c8a2d8a..20e7bbbac2 100644 --- a/etc/themes/wheatgrass-theme.el +++ b/etc/themes/wheatgrass-theme.el @@ -19,11 +19,14 @@ ;;; Code: +;;;###theme-autoload (deftheme wheatgrass "High-contrast green/blue/brown faces on a black background. Basic, Font Lock, Isearch, Gnus, and Message faces are included. The default face foreground is wheat, with other faces in shades -of green, brown, and blue.") +of green, brown, and blue." + :background-mode 'dark + :kind 'color-scheme) (let ((class '((class color) (min-colors 89)))) (custom-theme-set-faces diff --git a/etc/themes/whiteboard-theme.el b/etc/themes/whiteboard-theme.el index f21b18b421..2f86234b32 100644 --- a/etc/themes/whiteboard-theme.el +++ b/etc/themes/whiteboard-theme.el @@ -21,8 +21,11 @@ ;;; Code: +;;;###theme-autoload (deftheme whiteboard - "Face colors similar to markers on a whiteboard.") + "Face colors similar to markers on a whiteboard." + :background-mode 'light + :kind 'color-scheme) (let ((class '((class color) (min-colors 89)))) (custom-theme-set-faces diff --git a/etc/themes/wombat-theme.el b/etc/themes/wombat-theme.el index d9fab8ac78..9bb026ead1 100644 --- a/etc/themes/wombat-theme.el +++ b/etc/themes/wombat-theme.el @@ -21,11 +21,14 @@ ;;; Code: +;;;###theme-autoload (deftheme wombat "Medium-contrast faces with a dark gray background. Adapted, with permission, from a Vim color scheme by Lars H. Nielsen. Basic, Font Lock, Isearch, Gnus, Message, and Ansi-Color faces -are included.") +are included." + :background-mode 'dark + :kind 'color-scheme) (let ((class '((class color) (min-colors 89)))) (custom-theme-set-faces diff --git a/lisp/custom.el b/lisp/custom.el index 604b1a3ff4..5aecbe6fe5 100644 --- a/lisp/custom.el +++ b/lisp/custom.el @@ -1152,9 +1152,11 @@ custom--sort-vars-1 ;; (provide-theme 'THEME) -(defmacro deftheme (theme &optional doc) +(defmacro deftheme (theme &optional doc &rest properties) "Declare THEME to be a Custom theme. The optional argument DOC is a doc string describing the theme. +PROPERTIES are interpreted as a property list that will be stored +in the `theme-properties' property for THEME. Any theme `foo' should be defined in a file called `foo-theme.el'; see `custom-make-theme-feature' for more information." @@ -1164,18 +1166,25 @@ deftheme ;; It is better not to use backquote in this file, ;; because that makes a bootstrapping problem ;; if you need to recompile all the Lisp files using interpreted code. - (list 'custom-declare-theme (list 'quote theme) (list 'quote feature) doc))) + (list 'custom-declare-theme (list 'quote theme) (list 'quote feature) doc + (cons 'list properties)))) -(defun custom-declare-theme (theme feature &optional doc) +(defun custom-declare-theme (theme feature &optional doc properties) "Like `deftheme', but THEME is evaluated as a normal argument. -FEATURE is the feature this theme provides. Normally, this is a symbol -created from THEME by `custom-make-theme-feature'." +FEATURE is the feature this theme provides. Normally, this is a +symbol created from THEME by `custom-make-theme-feature'. The +optional argument DOC may contain the documentation for THEME. +The optional argument PROPERTIES may contain a property list of +attributes associated with THEME." (unless (custom-theme-name-valid-p theme) (error "Custom theme cannot be named %S" theme)) (unless (memq theme custom-known-themes) (push theme custom-known-themes)) (put theme 'theme-feature feature) - (when doc (put theme 'theme-documentation doc))) + (when doc + (put theme 'theme-documentation doc)) + (when properties + (put theme 'theme-properties properties))) (defun custom-make-theme-feature (theme) "Given a symbol THEME, create a new symbol by appending \"-theme\". @@ -1372,6 +1381,55 @@ load-theme (enable-theme theme)) t) +(defun theme-list-variants (theme &rest list) + "Return a list of theme variants for THEME. +If the optional argument LIST is not given, " + (let* ((properties (get theme 'theme-properties)) + (family (plist-get properties :family))) + (seq-filter + (lambda (variant) + (and (eq (plist-get (get variant 'theme-properties) :family) + family) + (not (eq variant theme)))) + (or list (custom-available-themes))))) + +(defun theme-choose-variant (&optional no-confirm no-enable) + "Prompt to switch from the current theme to one of its a variants. +The current theme will be disabled before variant is enabled. If +the current theme has only one variant, switch to that variant +without prompting, otherwise prompt for the variant to select. +See `load-theme' for the meaning of NO-CONFIRM and NO-ENABLE." + (interactive) + (let ((active-color-schemes + (seq-filter + (lambda (theme) + ;; FIXME: As most themes currently do not have a `:kind' + ;; tag, it is assumed that a theme is a color scheme by + ;; default. This should be reconsidered in the future. + (memq (plist-get (get theme 'theme-properties) :kind) + '(color-scheme nil))) + custom-enabled-themes))) + (cond + ((length= active-color-schemes 0) + (user-error "No theme is active, cannot toggle")) + ((length> active-color-schemes 1) + (user-error "More than one theme active, cannot unambiguously toggle"))) + (let* ((theme (car active-color-schemes)) + (family (plist-get (get theme 'theme-properties) :family))) + (unless family + (error "Theme `%s' does not have any known variants" theme)) + (let* ((variants (theme-list-variants theme)) + (choice (cond + ((null variants) + (error "`%s' has no variants" theme)) + ((length= variants 1) + (car variants)) + ((intern (completing-read "Load custom theme: " variants)))))) + (disable-theme theme) + (load-theme choice no-confirm no-enable))))) + +(defalias 'toggle-theme #'theme-choose-variant) + (defun custom-theme-load-confirm (hash) "Query the user about loading a Custom theme that may not be safe. The theme should be in the current buffer. If the user agrees, diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index 964d23c770..e57024aee5 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -283,6 +283,12 @@ loaddefs-generate--make-autoload ,@(when-let ((safe (plist-get props :safe))) `((put ',varname 'safe-local-variable ,safe)))))) + ;; Extract theme properties + ((eq car 'deftheme) + (let* ((name (car-safe (cdr-safe form))) + (props (nthcdr 3 form))) + `(put ',name 'theme-properties (list ,@props)))) + ((eq car 'defgroup) ;; In Emacs this is normally handled separately by cus-dep.el, but for ;; third party packages, it can be convenient to explicitly autoload -- 2.37.3 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Handle-theme-autoload-comments-in-etc-themes.patch >From a9bc4ba6b07aef118f05022486f9fc10a0e41e64 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Thu, 13 Oct 2022 10:43:36 +0200 Subject: [PATCH] Handle ;;;###theme-autoload comments in etc/themes * lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate--emacs-batch): Extract the autoloads and have them loaded along with loaddefs.el. --- lisp/emacs-lisp/loaddefs-gen.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index e57024aee5..39eec87f72 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -736,7 +736,15 @@ loaddefs-generate--emacs-batch ;; updated. (file-newer-than-file-p (expand-file-name "emacs-lisp/loaddefs-gen.el" lisp-directory) - output-file)))) + output-file))) + (let ((lisp-mode-autoload-regexp + "^;;;###\\(\\(noexist\\)-\\)?\\(theme-autoload\\)") + (output-file )) + (loaddefs-generate + (expand-file-name "../etc/themes/" lisp-directory) + (expand-file-name "theme-loaddefs.el" lisp-directory)))) + +;;;###autoload (load "theme-loaddefs.el") (provide 'loaddefs-gen) -- 2.37.3 --=-=-= Content-Type: text/plain Note that this includes changes to both the Leuven and Modus themes. --=-=-=--