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 22:19:20 +0000 Message-ID: <87czavicyf.fsf@posteo.net> References: <12653550-6233-db76-c8a4-70bd80173a9b@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16687"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen , Eli Zaretskii , Protesilaos Stavrou , 57639@debbugs.gnu.org To: Mauro Aranda Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Oct 14 00:20:18 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 1oj6Yr-000452-Bd for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 14 Oct 2022 00:20:17 +0200 Original-Received: from localhost ([::1]:33448 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oj6Yq-00014F-Cd for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 13 Oct 2022 18:20:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oj6Yc-00011P-H4 for bug-gnu-emacs@gnu.org; Thu, 13 Oct 2022 18:20:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36147) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oj6Yc-0001fe-6r for bug-gnu-emacs@gnu.org; Thu, 13 Oct 2022 18:20:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oj6Yb-0007t3-JI for bug-gnu-emacs@gnu.org; Thu, 13 Oct 2022 18:20: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 22:20: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.166569957730274 (code B ref 57639); Thu, 13 Oct 2022 22:20:01 +0000 Original-Received: (at 57639) by debbugs.gnu.org; 13 Oct 2022 22:19:37 +0000 Original-Received: from localhost ([127.0.0.1]:35225 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oj6YC-0007sD-M3 for submit@debbugs.gnu.org; Thu, 13 Oct 2022 18:19:37 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:33353) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oj6Y6-0007rh-UD for 57639@debbugs.gnu.org; Thu, 13 Oct 2022 18:19:35 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id F089B240103 for <57639@debbugs.gnu.org>; Fri, 14 Oct 2022 00:19:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1665699565; bh=0h8Lp/+XQYj46SHgUPRKgCOkYuE+PZPO9vOZu18WIeQ=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=lKTqmmB5IQZxXmEfCLtE7OC/ztkOXe5ohN0gHGb0TJpFprd+2/10DIUE+PGTjESmG WiNAgpyfDD3fB8A63xlpW4OkiufwLmDOQMROZ7uiDs9V6MMdHfWnCjuYemWQCvmCOQ 3fFx1NtLz4Lcf+AvG7vja0Wz2+GsRWO2XphKdUqYz5lEtU2GlUd5QahWBgcNlVQyIu LJpVClIkujOprqfkGfOAL9XxpL33yTMzlQhHyMgygFN68kFfoe4iiTBNlxBGFLSpbu PcPTv3tLsR7spzLACk/v+J5UfbGBjc7z2a/vuxfKgWwgZ1lCISMAOU5LRNmfHhm+yT 2WnivkH6lMADQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4MpP7s20RNz9rxB; Fri, 14 Oct 2022 00:19:21 +0200 (CEST) In-Reply-To: <12653550-6233-db76-c8a4-70bd80173a9b@gmail.com> (Mauro Aranda's message of "Thu, 13 Oct 2022 17:46:55 -0300") 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:245358 Archived-At: Mauro Aranda writes: > Hi Philip, > > Philip Kaludercic writes: > >> +Themes*} buffer.=C2=A0 The remaining arguments @var{properties} are used >> +pass a property list with theme attributes. > > I think this added sentence is not clear. > > Also, no documentation for these special properties for toggling themes? Currently no. >> +(defun theme-list-variants (theme &rest list) >> +=C2=A0 "Return a list of theme variants for THEME. >> +If the optional argument LIST is not given, " > > This docstring is incomplete. Fixed, thanks. >> +=C2=A0 (let* ((properties (get theme 'theme-properties)) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (family (plist-get pro= perties :family))) >> +=C2=A0=C2=A0=C2=A0 (seq-filter >> +=C2=A0=C2=A0=C2=A0=C2=A0 (lambda (variant) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (and (eq (plist-get (get variant '= theme-properties) :family) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 family) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (not= (eq variant theme)))) >> +=C2=A0=C2=A0=C2=A0=C2=A0 (or list (custom-available-themes))))) >> + >> +(defun theme-choose-variant (&optional no-confirm no-enable) >> +=C2=A0 "Prompt to switch from the current theme to one of its a variant= s. > > I'd say: "Command to switch..." Do you think it is necessary to point out that it is a command? >> +=C2=A0 (let ((active-color-schemes >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (seq-filter >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (lambda (theme) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ;; F= IXME: As most themes currently do not have a `:kind' >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ;; t= ag, it is assumed that a theme is a color scheme by >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ;; d= efault.=C2=A0 This should be reconsidered in the future. >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (mem= q (plist-get (get theme 'theme-properties) :kind) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 '(color-scheme nil))) > > I think that theme writers who care about this functionality will add > :kind and :family to the themes, and those who don't won't bother with > that.=C2=A0 So I don't really see the point in supporting (:kind nil). :kind nil will probably not occur in practice, it is just that `plist-get' will return nil if no :kind is specified. >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 custom-enabled-t= hemes))) >> +=C2=A0=C2=A0=C2=A0 (cond >> +=C2=A0=C2=A0=C2=A0=C2=A0 ((length=3D active-color-schemes 0) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (user-error "No theme is active, cannot = toggle")) > > This message will be confusing when there are themes whose :kind is not > color-scheme... How come? Or do you think that we should explicitly clarify that `theme-choose-variant' is just for color-schemes? >> +=C2=A0=C2=A0=C2=A0=C2=A0 ((length> active-color-schemes 1) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (user-error "More than one theme active,= cannot unambiguously > toggle"))) >> +=C2=A0=C2=A0=C2=A0 (let* ((theme (car active-color-schemes)) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (family (p= list-get (get theme 'theme-properties) :family))) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (unless family >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (error "Theme `%s' does not = have any known variants" theme)) > > This will pretty much always error with themes that don't really care > about toggling (see above).=C2=A0 Could you tell more about what is the > benefit of supporting (:kind nil)? I guess you are right in saying that nobody will set :family without setting :kind... But that won't change anything here, because what you describe is intended (a theme that has no variants, cannot be toggled.) >> --- a/lisp/emacs-lisp/loaddefs-gen.el >> +++ b/lisp/emacs-lisp/loaddefs-gen.el >> @@ -283,6 +283,12 @@ loaddefs-generate--make-autoload >>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = ,@(when-let ((safe (plist-get props :safe))) >>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 `((put ',varname 'safe-local-variable ,safe)))))) >> >> +=C2=A0=C2=A0=C2=A0=C2=A0 ;; Extract theme properties > > Full stop missing. Noted. >> +=C2=A0=C2=A0=C2=A0=C2=A0 ((eq car 'deftheme) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (let* ((name (car-safe (cdr-safe form))) >> +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 (props (nthcdr 3 form))) >> +=C2=A0=C2=A0=C2=A0 `(put ',name 'theme-properties (list ,@props)))) > > In the Autoload section of the Elisp Manual, we have this: > "The forms which are not copied verbatim are the following:..." > > Shouldn't deftheme be added to that list as well? Good point, will do.