emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 5c39f6f: Make sure we only act on edited widgets in Custom-save


From: Lars Ingebrigtsen
Subject: master 5c39f6f: Make sure we only act on edited widgets in Custom-save
Date: Fri, 14 Aug 2020 10:40:49 -0400 (EDT)

branch: master
commit 5c39f6f1165a33f5714eedd3a413f786dffbb5a2
Author: Mauro Aranda <maurooaranda@gmail.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    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).
---
 lisp/cus-edit.el | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index 5ec5799..23ceb3a 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]