From 0b65f607102c12260c7cca5df3d8586c2b1a24bd Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 5 May 2026 12:24:56 -0500 Subject: refactor!: demote chime-validation-max-retries to private defvar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is an internal startup-timing parameter, not a knob real users have reason to tune through `M-x customize'. I demoted it from defcustom to defvar and renamed it to `chime--validation-max-retries' to make the private status explicit. Anyone who was overriding it can keep doing so with `setq' (the variable still exists, just under the new name). The three customize-time validation tests went away with the defcustom — nothing left to validate at customize-time once it stops being a customize-target. The setter helper still applies to the other five numeric defcustoms. Test files that referenced the variable (`test-chime-validation-retry.el', `test-integration-chime-mode.el') were renamed mechanically along with the source. Breaking change: `(setq chime-validation-max-retries N)' becomes `(setq chime--validation-max-retries N)' if you actually had it. Most users won't have touched it. --- chime.el | 29 +++++++++------------------ tests/test-chime-numeric-defcustom-setters.el | 22 ++------------------ tests/test-chime-validation-retry.el | 24 +++++++++++----------- tests/test-integration-chime-mode.el | 2 +- 4 files changed, 25 insertions(+), 52 deletions(-) diff --git a/chime.el b/chime.el index 930a067..e843537 100644 --- a/chime.el +++ b/chime.el @@ -628,24 +628,15 @@ has elapsed. This gives startup hooks time to populate org-agenda-files.") Reset to 0 when validation succeeds. Used to provide graceful retry behavior for users with async org-agenda-files initialization.") -(defcustom chime-validation-max-retries 3 +(defvar chime--validation-max-retries 3 "Maximum number of times to retry validation before showing error. -When org-agenda-files is empty on startup, chime will retry validation -on each check cycle (every `chime-check-interval' seconds) until either: - - Validation succeeds (org-agenda-files is populated) - - This retry limit is exceeded (error is shown) +When `org-agenda-files' is empty on startup, chime will retry validation +on each check cycle (every `chime-check-interval' seconds) until either +validation succeeds or this retry limit is exceeded. -This accommodates users with async initialization code that populates -org-agenda-files after a delay (e.g., via idle timers). - -Set to 0 to show errors immediately without retrying. -Default is 3 retries (with 30-60s check intervals, this gives ~1.5-3 minutes -for org-agenda-files to be populated)." - :type 'integer - :group 'chime - :set (lambda (symbol value) - (chime--validate-integer-setting symbol value 0 nil) - (set-default symbol value))) +This is internal because no user has reason to tune the defensive +startup-timing window through Customize. If you need to override the +default for a specific environment, `setq' the variable in your init.") (defvar chime-modeline-string nil "Modeline string showing next upcoming event.") @@ -1852,7 +1843,7 @@ Returns nil if validation failed and check should be skipped." (if (cl-some (lambda (i) (eq (car i) :error)) issues) (progn (setq chime--validation-retry-count (1+ chime--validation-retry-count)) - (if (> chime--validation-retry-count chime-validation-max-retries) + (if (> chime--validation-retry-count chime--validation-max-retries) (progn (let ((errors (cl-remove-if-not (lambda (i) (eq (car i) :error)) issues))) (chime--log-silently "Chime: Configuration validation failed with %d error(s) after %d retries:" @@ -1866,12 +1857,12 @@ Returns nil if validation failed and check should be skipped." (chime--set-modeline-error-state "Configuration error — check *Messages* buffer")) (message "Chime: Waiting for org-agenda-files to load... (attempt %d/%d)" chime--validation-retry-count - chime-validation-max-retries) + chime--validation-max-retries) ;; Update modeline tooltip to show waiting state (chime--set-modeline-error-state (format "Waiting for org-agenda-files... (attempt %d/%d)" chime--validation-retry-count - chime-validation-max-retries))) + chime--validation-max-retries))) nil) (setq chime--validation-done t) (setq chime--validation-retry-count 0) diff --git a/tests/test-chime-numeric-defcustom-setters.el b/tests/test-chime-numeric-defcustom-setters.el index 03d7810..7fb5afa 100644 --- a/tests/test-chime-numeric-defcustom-setters.el +++ b/tests/test-chime-numeric-defcustom-setters.el @@ -161,26 +161,8 @@ 'chime-max-consecutive-failures -1) :type 'user-error))) -;;;; chime-validation-max-retries — integer >= 0 - -(ert-deftest test-chime-validation-max-retries-accepts-zero () - "Normal: 0 means show errors immediately without retrying (per docstring)." - (let ((chime-validation-max-retries 3)) - (customize-set-variable 'chime-validation-max-retries 0) - (should (= 0 chime-validation-max-retries)))) - -(ert-deftest test-chime-validation-max-retries-accepts-positive () - "Normal: positive integer is valid." - (let ((chime-validation-max-retries 3)) - (customize-set-variable 'chime-validation-max-retries 5) - (should (= 5 chime-validation-max-retries)))) - -(ert-deftest test-chime-validation-max-retries-rejects-negative () - "Error: negative retry count is meaningless." - (let ((chime-validation-max-retries 3)) - (should-error (customize-set-variable - 'chime-validation-max-retries -1) - :type 'user-error))) +;; Note: `chime--validation-max-retries' was demoted from defcustom to +;; defvar in 0.8 — no customize-time setter, no validation tests here. (provide 'test-chime-numeric-defcustom-setters) ;;; test-chime-numeric-defcustom-setters.el ends here diff --git a/tests/test-chime-validation-retry.el b/tests/test-chime-validation-retry.el index b4e886c..70188bc 100644 --- a/tests/test-chime-validation-retry.el +++ b/tests/test-chime-validation-retry.el @@ -12,7 +12,7 @@ ;; ;; Components tested: ;; - chime--validation-retry-count tracking -;; - chime-validation-max-retries configuration +;; - chime--validation-max-retries configuration ;; - chime-check validation retry logic ;; - chime--stop retry counter reset ;; - Message display behavior (waiting vs error) @@ -24,7 +24,7 @@ ;;; Setup and Teardown (defvar test-chime-validation-retry--original-max-retries nil - "Original value of chime-validation-max-retries for restoration.") + "Original value of chime--validation-max-retries for restoration.") (defvar test-chime-validation-retry--original-agenda-files nil "Original value of org-agenda-files for restoration.") @@ -32,7 +32,7 @@ (defun test-chime-validation-retry-setup () "Set up test environment before each test." ;; Save original values - (setq test-chime-validation-retry--original-max-retries chime-validation-max-retries) + (setq test-chime-validation-retry--original-max-retries chime--validation-max-retries) (setq test-chime-validation-retry--original-agenda-files org-agenda-files) ;; Reset validation state @@ -40,12 +40,12 @@ (setq chime--validation-retry-count 0) ;; Set predictable defaults - (setq chime-validation-max-retries 3)) + (setq chime--validation-max-retries 3)) (defun test-chime-validation-retry-teardown () "Clean up test environment after each test." ;; Restore original values - (setq chime-validation-max-retries test-chime-validation-retry--original-max-retries) + (setq chime--validation-max-retries test-chime-validation-retry--original-max-retries) (setq org-agenda-files test-chime-validation-retry--original-agenda-files) ;; Reset validation state @@ -179,14 +179,14 @@ process events normally." (ert-deftest test-chime-validation-retry-boundary-max-retries-zero () "Test max-retries=0 shows error immediately without retrying. -When chime-validation-max-retries is set to 0, validation failures +When chime--validation-max-retries is set to 0, validation failures should immediately show the full error message without any retry attempts." (test-chime-validation-retry-setup) (unwind-protect (progn ;; Set max retries to 0 - (setq chime-validation-max-retries 0) + (setq chime--validation-max-retries 0) ;; Empty org-agenda-files (setq org-agenda-files nil) @@ -222,7 +222,7 @@ show full error." (unwind-protect (progn ;; Set max retries to 1 - (setq chime-validation-max-retries 1) + (setq chime--validation-max-retries 1) ;; Empty org-agenda-files (setq org-agenda-files nil) @@ -261,7 +261,7 @@ The (retry_count + 1)th attempt should show the error message." (unwind-protect (progn ;; Default max retries = 3 - (setq chime-validation-max-retries 3) + (setq chime--validation-max-retries 3) (setq org-agenda-files nil) (cl-letf (((symbol-function 'chime--fetch-and-process) @@ -346,7 +346,7 @@ displayed with all error details in the *Messages* buffer." (test-chime-validation-retry-setup) (unwind-protect (progn - (setq chime-validation-max-retries 2) + (setq chime--validation-max-retries 2) (setq org-agenda-files nil) (cl-letf (((symbol-function 'chime--fetch-and-process) @@ -380,7 +380,7 @@ validation should never be marked as done." (test-chime-validation-retry-setup) (unwind-protect (progn - (setq chime-validation-max-retries 3) + (setq chime--validation-max-retries 3) (setq org-agenda-files nil) (cl-letf (((symbol-function 'chime--fetch-and-process) @@ -406,7 +406,7 @@ many retry attempts, ensuring no integer overflow issues." (test-chime-validation-retry-setup) (unwind-protect (progn - (setq chime-validation-max-retries 1000) + (setq chime--validation-max-retries 1000) (setq org-agenda-files nil) (cl-letf (((symbol-function 'chime--fetch-and-process) diff --git a/tests/test-integration-chime-mode.el b/tests/test-integration-chime-mode.el index cd1fec5..40436fb 100644 --- a/tests/test-integration-chime-mode.el +++ b/tests/test-integration-chime-mode.el @@ -105,7 +105,7 @@ in the tooltip, not go blank." (org-agenda-files nil) (chime--validation-done nil) (chime--validation-retry-count 0) - (chime-validation-max-retries 0)) + (chime--validation-max-retries 0)) (unwind-protect (progn (chime-mode 1) -- cgit v1.2.3