Subject: Re: bug#44331: 28.0.50; Customize won't save a face setting, if not set first

From: Mauro Aranda <[email-masked]>
Date: Fri, 30 Oct 2020 13:23:06 -0300

tags 44331 patch
quit

Looks like this was introduced in the fix for Bug#40866.  When only
customizing for the selected terminal, now we recreate the custom-face
widget for all kind of displays, but lose the user editions in the
process of doing that.

The attached patch fixes it, because it records the edited value in
the :shown-value property, which a custom widget prioritizes over
everything else, when finding out the value of the face.
From c3f92a5431defff64c6956bbcbee12638ae4ecef Mon Sep 17 00:00:00 2001
From: Mauro Aranda <[email-masked]>
Date: Fri, 30 Oct 2020 13:05:08 -0300
Subject: [PATCH] Fix saving a face setting with Customize

* lisp/cus-edit.el (custom-face-save): Make sure we back up into the
:shown-value property what the user has edited so far, if we are going
to recreate the custom-face widget.  (Bug#44331)
---
 lisp/cus-edit.el | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index 769a69a50f..01dec6964d 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -3931,6 +3931,10 @@ custom-face-save
         (custom-face-mark-to-save widget)
       ;; The user is working on only a selected terminal type;
       ;; make sure we save the entire spec to `custom-file'. (Bug #40866)
+      ;; If recreating a widget that may have been edited by the user, remember
+      ;; to always save the edited value into the :shown-value property, so
+      ;; we use that value for the recreated widget.  (Bug#44331)
+      (widget-put widget :shown-value (custom-face-widget-to-spec widget))
       (custom-face-edit-all widget)
       (custom-face-mark-to-save widget)
       (if (eq form 'selected)
-- 
2.29.0