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 21:57:51 -0400 Message-ID: <77d32b46f062bc1dac34220709a8175f@contrapunctus.net> References: <87fsx0i5he.fsf@tbb.theblackbeard.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36753"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Roundcube Webmail/1.4.11 Cc: 49274@debbugs.gnu.org To: Mauro Aranda Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 30 10:31:24 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 1lyVcx-0009H9-QR for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 30 Jun 2021 10:31:23 +0200 Original-Received: from localhost ([::1]:40120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyVcv-0005dq-SD for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 30 Jun 2021 04:31:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51736) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyVcd-0005cJ-4H for bug-gnu-emacs@gnu.org; Wed, 30 Jun 2021 04:31:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44871) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lyVcc-0003nr-N1 for bug-gnu-emacs@gnu.org; Wed, 30 Jun 2021 04:31:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lyVcc-0006SF-LB for bug-gnu-emacs@gnu.org; Wed, 30 Jun 2021 04:31: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: Wed, 30 Jun 2021 08:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49274 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 49274-submit@debbugs.gnu.org id=B49274.162504182924741 (code B ref 49274); Wed, 30 Jun 2021 08:31:02 +0000 Original-Received: (at 49274) by debbugs.gnu.org; 30 Jun 2021 08:30:29 +0000 Original-Received: from localhost ([127.0.0.1]:56412 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyVc4-0006Qt-Sk for submit@debbugs.gnu.org; Wed, 30 Jun 2021 04:30:29 -0400 Original-Received: from relay5-d.mail.gandi.net ([217.70.183.197]:42221) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyPUF-000575-AO for 49274@debbugs.gnu.org; Tue, 29 Jun 2021 21:58:00 -0400 Original-Received: (Authenticated sender: league@contrapunctus.net) by relay5-d.mail.gandi.net (Postfix) with ESMTPA id 324B01C0004; Wed, 30 Jun 2021 01:57:51 +0000 (UTC) In-Reply-To: <87fsx0i5he.fsf@tbb.theblackbeard.org> X-Sender: league@contrapunctus.net X-Mailman-Approved-At: Wed, 30 Jun 2021 04:30:26 -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:209144 Archived-At: On 2021-06-29 20:03, Mauro Aranda wrote: > That's because there was a change to the :format property of the text > widget, but this call wasn't updated. Try overriding it like this: > (widget-create 'text :format "%v" ...) > > The above should make it work. Please try it, thank you. Yes, that works. I'm including an updated patch below. Thanks. CL From 390ed4d6adf83e66b2f1d78637c071babbe62029 Mon Sep 17 00:00:00 2001 From: Christopher League Date: Mon, 28 Jun 2021 22:41:07 -0400 Subject: [PATCH] lisp/cus-theme: retain documentation string when customizing theme 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