aboutsummaryrefslogtreecommitdiff
path: root/tests/test-system-defaults.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-25 18:29:32 -0500
committerCraig Jennings <c@cjennings.net>2026-05-25 18:29:32 -0500
commit391c6ce1edb9f668235b469e5e5798f8b02ce966 (patch)
tree862a2daf3af5a456b612c3287aa14c68380cd215 /tests/test-system-defaults.el
parentebd93c16cf04933d3e717d4b2a497885157e5bb9 (diff)
downloaddotemacs-391c6ce1edb9f668235b469e5e5798f8b02ce966.tar.gz
dotemacs-391c6ce1edb9f668235b469e5e5798f8b02ce966.zip
feat(system-defaults): warn once when Customize tries to save
custom-file points at a throwaway temp file so Customize edits never persist — deliberate, since config lives in Elisp, but silent. A user who clicks "Save for Future Sessions" loses the edit on exit with no hint. I advise custom-save-all (the chokepoint both customize-save-variable and the Customize button funnel through) with a one-shot :before warning that explains the discard and points at the Elisp init files. The advice removes itself after firing, so it warns once per session, and the body never runs at load, so startup stays quiet.
Diffstat (limited to 'tests/test-system-defaults.el')
-rw-r--r--tests/test-system-defaults.el20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test-system-defaults.el b/tests/test-system-defaults.el
index bc3694dba..3c5e59777 100644
--- a/tests/test-system-defaults.el
+++ b/tests/test-system-defaults.el
@@ -64,5 +64,25 @@ they are actually wired onto the minibuffer hooks."
(should (memq 'cj/minibuffer-setup-hook minibuffer-setup-hook))
(should (memq 'cj/minibuffer-exit-hook minibuffer-exit-hook)))))
+;;; Customize-save warning
+
+(ert-deftest test-system-defaults-customize-save-warns-once ()
+ "Normal: the first custom-save-all warns; the second does not (one-shot).
+Customize writes land in a throwaway custom-file, so the user must be told
+their edit will not persist. The advice removes itself after warning once."
+ (test-system-defaults--with-load-environment
+ (let ((warnings '()))
+ (cl-letf (((symbol-function 'display-warning)
+ (lambda (group &rest _) (push group warnings)))
+ ((symbol-function 'custom-save-all) #'ignore))
+ (test-system-defaults--load)
+ ;; No warning merely from loading the module.
+ (should (null warnings))
+ (custom-save-all)
+ (should (equal warnings '(cj/system-defaults)))
+ ;; Second save must not warn again.
+ (custom-save-all)
+ (should (equal warnings '(cj/system-defaults)))))))
+
(provide 'test-system-defaults)
;;; test-system-defaults.el ends here