Make sure we only act on edited widgets in Custom-save

* lisp/cus-edit.el (Custom-save): Only act on edited widgets in the
buffer.  If we attempt to redraw all widgets, we confuse
custom-variable-modified-p, or we end up drawing State buttons for
all options, including the hidden ones (bug#42801).
This commit is contained in:
Mauro Aranda
2020-08-14 16:40:40 +02:00
committed by Lars Ingebrigtsen
parent 93136b980a
commit 5c39f6f116

View File

@@ -801,16 +801,19 @@ has been executed, nil otherwise."
If a setting was edited and set before, this saves it. If a
setting was merely edited before, this sets it then saves it."
(interactive)
(when (custom-command-apply
(lambda (child)
(when (memq (widget-get child :custom-state)
'(modified set changed rogue))
(widget-apply child :custom-mark-to-save)))
"Save all settings in this buffer? " t)
;; Save changes to buffer and redraw.
(custom-save-all)
(dolist (child custom-options)
(widget-apply child :custom-state-set-and-redraw))))
(let (edited-widgets)
(when (custom-command-apply
(lambda (child)
(when (memq (widget-get child :custom-state)
'(modified set changed rogue))
(push child edited-widgets)
(widget-apply child :custom-mark-to-save)))
"Save all settings in this buffer? " t)
;; Save changes to buffer.
(custom-save-all)
;; Redraw and recalculate the state when necessary.
(dolist (widget edited-widgets)
(widget-apply widget :custom-state-set-and-redraw)))))
(defun custom-reset (_widget &optional event)
"Select item from reset menu."