diff options
| -rw-r--r-- | chime.el | 51 |
1 files changed, 25 insertions, 26 deletions
@@ -1799,29 +1799,17 @@ FORMAT-STRING and ARGS are passed to `format'." (insert (apply #'format format-string args)) (unless (bolp) (insert "\n"))))) -;;;###autoload -(cl-defun chime-check () - "Parse agenda view and notify about upcoming events. - -Do nothing if a check is already in progress in the background. - -On the first call after `chime-mode' is enabled, validates the runtime -configuration. This happens after `chime-startup-delay', giving startup -hooks time to populate org-agenda-files. If validation fails, logs an -error and skips the check." - (interactive) - - ;; Validate configuration on first check only - (unless chime--validation-done +(defun chime--maybe-validate () + "Run startup validation if not yet done. Return t if OK to proceed. +Handles retry logic for async org-agenda-files initialization. +Returns nil if validation failed and check should be skipped." + (if chime--validation-done + t (let ((issues (chime-validate-configuration))) (if (cl-some (lambda (i) (eq (car i) :error)) issues) (progn - ;; Critical errors found - increment retry counter (setq chime--validation-retry-count (1+ chime--validation-retry-count)) - - ;; Check if we've exceeded max retries (if (> chime--validation-retry-count chime-validation-max-retries) - ;; Max retries exceeded - show full error (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:" (length errors) @@ -1830,18 +1818,29 @@ error and skips the check." (chime--log-silently "") (chime--log-silently "ERROR: %s" (cadr err))) (message "Chime: Configuration errors detected (see *Messages* buffer for details)")) - ;; Still within retry limit - show friendly waiting message (message "Chime: Waiting for org-agenda-files to load... (attempt %d/%d)" chime--validation-retry-count chime-validation-max-retries)) - - ;; Don't mark validation as done - will retry on next check - ;; in case dependencies load later - ;; Don't proceed with check - (cl-return-from chime-check nil)) - ;; No errors - mark validation as done and reset retry counter + nil) (setq chime--validation-done t) - (setq chime--validation-retry-count 0)))) + (setq chime--validation-retry-count 0) + t)))) + +;;;###autoload +(cl-defun chime-check () + "Parse agenda view and notify about upcoming events. + +Do nothing if a check is already in progress in the background. + +On the first call after `chime-mode' is enabled, validates the runtime +configuration. This happens after `chime-startup-delay', giving startup +hooks time to populate org-agenda-files. If validation fails, logs an +error and skips the check." + (interactive) + + ;; Validate configuration on first check only + (unless (chime--maybe-validate) + (cl-return-from chime-check nil)) ;; Validation passed or already done - proceed with check (chime--fetch-and-process |
