From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Christopher League Newsgroups: gmane.emacs.bugs Subject: bug#49274: [PATCH] lisp/cus-theme: retain documentation string when customizing theme Date: Tue, 29 Jun 2021 10:44:12 -0400 Message-ID: <20210629144412.455196-1-league@contrapunctus.net> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20570"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Christopher League To: 49274@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jun 29 17:34:35 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 1lyFkx-0005CH-4N for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 29 Jun 2021 17:34:35 +0200 Original-Received: from localhost ([::1]:56976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyFkw-0006vD-49 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 29 Jun 2021 11:34:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyFkQ-0006dY-Fi for bug-gnu-emacs@gnu.org; Tue, 29 Jun 2021 11:34:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43609) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lyFkQ-0000yP-74 for bug-gnu-emacs@gnu.org; Tue, 29 Jun 2021 11:34:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lyFkQ-0000Fd-2D for bug-gnu-emacs@gnu.org; Tue, 29 Jun 2021 11:34:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Christopher League Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 29 Jun 2021 15:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 49274 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.1624980805913 (code B ref -1); Tue, 29 Jun 2021 15:34:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 29 Jun 2021 15:33:25 +0000 Original-Received: from localhost ([127.0.0.1]:55155 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyFjo-0000Ee-Um for submit@debbugs.gnu.org; Tue, 29 Jun 2021 11:33:25 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:52890) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyEyZ-0007VB-Rp for submit@debbugs.gnu.org; Tue, 29 Jun 2021 10:44:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyEyZ-0003oE-HG for bug-gnu-emacs@gnu.org; Tue, 29 Jun 2021 10:44:35 -0400 Original-Received: from relay6-d.mail.gandi.net ([217.70.183.198]:42683) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyEyW-0002Hm-Lx for bug-gnu-emacs@gnu.org; Tue, 29 Jun 2021 10:44:34 -0400 Original-Received: (Authenticated sender: league@contrapunctus.net) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 2ED02C001A; Tue, 29 Jun 2021 14:44:26 +0000 (UTC) X-Mailer: git-send-email 2.31.1 Received-SPF: pass client-ip=217.70.183.198; envelope-from=league@contrapunctus.net; helo=relay6-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 29 Jun 2021 11:33:24 -0400 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:209107 Archived-At: When editing an existing theme using `custom-theme-visit-theme`, the theme's documentation string would always be discarded and replaced with "Created DATE." With this improvement, the existing theme documentation string (if available) will be presented and editable in the widget, and emitted in the `deftheme` declaration when saved. A newly-created theme or an existing theme with no documentation string will get the "Created DATE" as before. *Implementation details:* we had to move the chunk marked "Load the theme settings" earlier in the function `customize-create-theme`. Then the `custom-theme-description` widget was made an `editable-field` whose value comes from `theme-documentation` if available, else `format-time-string`. The rest of the patch is reindentation due to the larger scope of the let that holds the theme settings. *Steps to reproduce the issue:* ``` % emacs -Q M-x custom-theme-visit-theme RET tango RET ``` *Result before this patch:* In the Custom Theme buffer, the Description field has the text `Created 2021-06-29.` followed by the editable widget containing the same string a second time. *Result after this patch:* The Description field has the text "Face colors using the Tango palette (light background) ..." -- the documentation string provided to `deftheme` in `etc/themes/tango-theme.el`. --- lisp/cus-theme.el | 100 +++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/lisp/cus-theme.el b/lisp/cus-theme.el index dfa2226403..3741f286e9 100644 --- a/lisp/cus-theme.el +++ b/lisp/cus-theme.el @@ -108,60 +108,16 @@ named *Custom Theme*." (unless (y-or-n-p "Include basic face customizations in this theme? ") (setq custom-theme--listed-faces nil))) - (if (eq theme 'user) - (widget-insert "This buffer contains all the Custom settings you have made. -You can convert them into a new custom theme, and optionally -remove them from your saved Custom file.\n\n")) - - (widget-create 'push-button - :tag " Visit Theme " - :help-echo "Insert the settings of a pre-defined theme." - :action (lambda (_widget &optional _event) - (call-interactively #'custom-theme-visit-theme))) - (widget-insert " ") - (widget-create 'push-button - :tag " Merge Theme " - :help-echo "Merge in the settings of a pre-defined theme." - :action (lambda (_widget &optional _event) - (call-interactively #'custom-theme-merge-theme))) - (widget-insert " ") - (widget-create 'push-button - :tag " Revert " - :help-echo "Revert this buffer to its original state." - :action (lambda (&rest ignored) (revert-buffer))) - - (widget-insert "\n\nTheme name : ") - (setq custom-theme-name - (widget-create 'editable-field - :value (if (and theme (not (eq theme 'user))) - (symbol-name theme) - ""))) - (widget-insert "Description: ") - (setq custom-theme-description - (widget-create 'text - :value (format-time-string "Created %Y-%m-%d."))) - (widget-create 'push-button - :notify #'custom-theme-write - " Save Theme ") - (when (eq theme 'user) - (setq custom-theme--migrate-settings t) - (widget-insert " ") - (widget-create 'checkbox - :value custom-theme--migrate-settings - :action (lambda (widget &optional event) - (when (widget-value widget) - (widget-toggle-action widget event) - (setq custom-theme--migrate-settings - (widget-value widget))))) - (widget-insert (propertize " Remove saved theme settings from Custom save file." - 'face '(variable-pitch (:height 0.9))))) - (let (vars values faces face-specs) ;; Load the theme settings. (when theme - (unless (eq theme 'user) - (load-theme theme nil t)) + (if (eq theme 'user) + (widget-insert "This buffer contains all the Custom settings you have made. +You can convert them into a new custom theme, and optionally +remove them from your saved Custom file.\n\n") + (load-theme theme nil t)) + (dolist (setting (get theme 'theme-settings)) (if (eq (car setting) 'theme-value) (progn (push (nth 1 setting) vars) @@ -169,6 +125,50 @@ remove them from your saved Custom file.\n\n")) (push (nth 1 setting) faces) (push (nth 3 setting) face-specs)))) + (widget-create 'push-button + :tag " Visit Theme " + :help-echo "Insert the settings of a pre-defined theme." + :action (lambda (_widget &optional _event) + (call-interactively #'custom-theme-visit-theme))) + (widget-insert " ") + (widget-create 'push-button + :tag " Merge Theme " + :help-echo "Merge in the settings of a pre-defined theme." + :action (lambda (_widget &optional _event) + (call-interactively #'custom-theme-merge-theme))) + (widget-insert " ") + (widget-create 'push-button + :tag " Revert " + :help-echo "Revert this buffer to its original state." + :action (lambda (&rest ignored) (revert-buffer))) + + (widget-insert "\n\nTheme name : ") + (setq custom-theme-name + (widget-create 'editable-field + :value (if (and theme (not (eq theme 'user))) + (symbol-name theme) + ""))) + (widget-insert "Description: ") + (setq custom-theme-description + (widget-create 'editable-field + :value (or (get theme 'theme-documentation) + (format-time-string "Created %Y-%m-%d.")))) + (widget-create 'push-button + :notify #'custom-theme-write + " Save Theme ") + (when (eq theme 'user) + (setq custom-theme--migrate-settings t) + (widget-insert " ") + (widget-create 'checkbox + :value custom-theme--migrate-settings + :action (lambda (widget &optional event) + (when (widget-value widget) + (widget-toggle-action widget event) + (setq custom-theme--migrate-settings + (widget-value widget))))) + (widget-insert (propertize " Remove saved theme settings from Custom save file." + 'face '(variable-pitch (:height 0.9))))) + ;; If THEME is non-nil, insert all of that theme's faces. ;; Otherwise, insert those in `custom-theme--listed-faces'. (widget-insert "\n\n Theme faces:\n ") -- 2.31.1