Skip to content

Commit bcb5bdc

Browse files
maurooarandaEli-Zaretskii
authored andcommitted
Pass original spec just after creating the face-widget
* lisp/cus-edit.el (custom-face-get-current-spec-unfiltered): New function, extracted from custom-face-get-current-spec. (custom-face-get-current-spec): Use it. (custom-face-state-set): Take an optional argument, to decide if we should check against a filtered or unfiltered spec. (custom-face-value-create): Use the new optional argument. (Bug#64347)
1 parent f9bbe31 commit bcb5bdc

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

lisp/cus-edit.el

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3721,7 +3721,8 @@ WIDGET should be a `custom-face' widget."
37213721
`((t ,(widget-value child)))
37223722
(widget-value child)))))
37233723

3724-
(defun custom-face-get-current-spec (face)
3724+
(defun custom-face-get-current-spec-unfiltered (face)
3725+
"Return the current spec for face FACE, without filtering it."
37253726
(let ((spec (or (get face 'customized-face)
37263727
(get face 'saved-face)
37273728
(get face 'face-defface-spec)
@@ -3732,7 +3733,11 @@ WIDGET should be a `custom-face' widget."
37323733
;; edit it as the user has specified it.
37333734
(if (not (face-spec-match-p face spec (selected-frame)))
37343735
(setq spec `((t ,(face-attr-construct face (selected-frame))))))
3735-
(custom-pre-filter-face-spec spec)))
3736+
spec))
3737+
3738+
(defun custom-face-get-current-spec (face)
3739+
"Return the current spec for face FACE, filtering it."
3740+
(custom-pre-filter-face-spec (custom-face-get-current-spec-unfiltered face)))
37363741

37373742
(defun custom-toggle-hide-face (visibility-widget &rest _ignore)
37383743
"Toggle the visibility of a `custom-face' parent widget.
@@ -3852,8 +3857,8 @@ the present value is saved to its :shown-value property instead."
38523857
(unless (widget-get widget :custom-form)
38533858
(widget-put widget :custom-form custom-face-default-form))
38543859

3855-
(let* ((spec (or (widget-get widget :shown-value)
3856-
(custom-face-get-current-spec symbol)))
3860+
(let* ((shown-value (widget-get widget :shown-value))
3861+
(spec (or shown-value (custom-face-get-current-spec symbol)))
38573862
(form (widget-get widget :custom-form))
38583863
(indent (widget-get widget :indent))
38593864
face-alist face-entry spec-default spec-match editor)
@@ -3894,7 +3899,7 @@ the present value is saved to its :shown-value property instead."
38943899
widget 'sexp :value spec))))
38953900
(push editor children)
38963901
(widget-put widget :children children)
3897-
(custom-face-state-set widget))))))
3902+
(custom-face-state-set widget (not shown-value)))))))
38983903

38993904
(defun cus--face-link (widget _format)
39003905
(widget-create-child-and-convert
@@ -4014,13 +4019,18 @@ This is one of `set', `saved', `changed', `themed', or `rogue'."
40144019
'changed
40154020
state)))
40164021

4017-
(defun custom-face-state-set (widget)
4022+
(defun custom-face-state-set (widget &optional no-filter)
40184023
"Set the state of WIDGET, a custom-face widget.
40194024
If the user edited the widget, set the state to modified. If not, the new
4020-
state is one of the return values of `custom-face-state'."
4025+
state is one of the return values of `custom-face-state'.
4026+
Optional argument NO-FILTER means to check against an unfiltered spec."
40214027
(let ((face (widget-value widget)))
40224028
(widget-put widget :custom-state
4023-
(if (face-spec-match-p face (custom-face-widget-to-spec widget))
4029+
(if (face-spec-match-p
4030+
face
4031+
(if no-filter
4032+
(custom-face-get-current-spec-unfiltered face)
4033+
(custom-face-widget-to-spec widget)))
40244034
(custom-face-state face)
40254035
'modified))))
40264036

0 commit comments

Comments
 (0)