From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mauro Aranda Newsgroups: gmane.emacs.bugs Subject: bug#57639: [PATCH] Add new command 'toggle-theme' Date: Thu, 13 Oct 2022 17:46:55 -0300 Message-ID: <12653550-6233-db76-c8a4-70bd80173a9b@gmail.com> References: <875yhzmz25.fsf@posteo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5462"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Cc: Lars Ingebrigtsen , Eli Zaretskii , Protesilaos Stavrou , 57639@debbugs.gnu.org To: Philip Kaludercic Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 13 22:49:04 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 1oj58Z-0001G8-QC for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 13 Oct 2022 22:49:03 +0200 Original-Received: from localhost ([::1]:60356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oj58Y-0004MD-Jp for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 13 Oct 2022 16:49:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52964) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oj57a-00047Y-PZ for bug-gnu-emacs@gnu.org; Thu, 13 Oct 2022 16:48:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35999) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oj57Z-0004as-Mo for bug-gnu-emacs@gnu.org; Thu, 13 Oct 2022 16:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oj57Z-0005DV-HH for bug-gnu-emacs@gnu.org; Thu, 13 Oct 2022 16:48:01 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <875yhzmz25.fsf@posteo.net> Resent-From: Mauro Aranda Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 13 Oct 2022 20:48: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.166569403019891 (code B ref 57639); Thu, 13 Oct 2022 20:48:01 +0000 Original-Received: (at 57639) by debbugs.gnu.org; 13 Oct 2022 20:47:10 +0000 Original-Received: from localhost ([127.0.0.1]:35077 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oj56k-0005Al-AY for submit@debbugs.gnu.org; Thu, 13 Oct 2022 16:47:10 -0400 Original-Received: from mail-oa1-f43.google.com ([209.85.160.43]:45028) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oj56g-00059m-DF for 57639@debbugs.gnu.org; Thu, 13 Oct 2022 16:47:08 -0400 Original-Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-132b8f6f1b2so3677703fac.11 for <57639@debbugs.gnu.org>; Thu, 13 Oct 2022 13:47:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=nhyhCIYTxzzgerN9fIPIcQqmV+UaTI2N8Fac3bugajU=; b=plppYsfzCj3wQPmT7ENhve7hP6Rzw5s5T2fk18VelUFfWp9CxAEWvwizMN/6vKMYLa 9th4LeR00RPlKsHIJKIebOr4eEKRNDisgxlLPPreqqjErzsjYQI1qRhLGSSAPNA4IzwR ciylKtodpF4hgPQlHiyj91MNQChJ1VKaMAvZdrCNyOzrgaR6AdSaK1hfEf11VnymXPu/ fViQTPPN8ZrIwhpaXkb3uWz0vsc4VI5Y4W1r8Aj5fmoy83DNywbjIWxS7OvwGHw2dNxs kJ85mPXXMgURXg82x0dxP/AZ4pCUy7siI3TyRuhxSO3ZLmO9BgXHWGOrCAClGteQ4SA+ oOMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=nhyhCIYTxzzgerN9fIPIcQqmV+UaTI2N8Fac3bugajU=; b=6s5pOhWp28Nw6QTrBKzbRsET7TcJRnVUdoXXXHT9Cp3tiarCT/1tWq4h1TJb0bNtLO SkHYYkOjYLJVSURU2JJO4vmsAc8zeYTSgy4BsLhdnDwgeSxaOYxTP3n+p3qNEqt3SHr0 CjwsB4TQQqKIyA7P73ZD7xh9qpWapga9HKcJQ5G2y4+Fsp2x0OYA6LnsU7NM3IqSkr7K OrCMWVvJlrua7JET6RKr8CcP4Gf2db2tVlZWc2h1dSFBDeFCRJ0regV39ww9TBr6JpWY KCB3aSO+++iawtbE0FIBvuqM1fVHxVa5yDe6XnfwhpWBHB4/zVbfXIbz0XP0rAp0hg3U Aw0w== X-Gm-Message-State: ACrzQf0zZpRKVNCSwZCU1wM6j4/2odjEqRly6lopfM77DQ0QZaPjt6lp rzeZb5hPc7ghDcRwjTdEjLA= X-Google-Smtp-Source: AMsMyM7jKKHg0GHXJoJ7zYHZZFqrB+tgZtEdjC4x0Xn9jp8YjiXq5hUZ5FIwB8rVogjkvn22p4o2vQ== X-Received: by 2002:a05:6870:d192:b0:133:1f1c:f680 with SMTP id a18-20020a056870d19200b001331f1cf680mr6670780oac.277.1665694020295; Thu, 13 Oct 2022 13:47:00 -0700 (PDT) Original-Received: from [192.168.0.234] ([181.228.28.240]) by smtp.gmail.com with ESMTPSA id z7-20020a056870e30700b0012c52bd4369sm521826oad.19.2022.10.13.13.46.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Oct 2022 13:46:59 -0700 (PDT) Content-Language: en-US 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:245356 Archived-At: Hi Philip, Philip Kaludercic writes: > +Themes*} buffer.  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? > +(defun theme-list-variants (theme &rest list) > +  "Return a list of theme variants for THEME. > +If the optional argument LIST is not given, " This docstring is incomplete. > +  (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. I'd say: "Command to switch..." > +  (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))) 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.  So I don't really see the point in supporting (:kind nil). > +          custom-enabled-themes))) > +    (cond > +     ((length= active-color-schemes 0) > +      (user-error "No theme is active, cannot toggle")) This message will be confusing when there are themes whose :kind is not color-scheme... > +     ((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)) This will pretty much always error with themes that don't really care about toggling (see above).  Could you tell more about what is the benefit of supporting (:kind nil)? > --- 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 Full stop missing. > +     ((eq car 'deftheme) > +      (let* ((name (car-safe (cdr-safe form))) > +         (props (nthcdr 3 form))) > +    `(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?