summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2025-11-17 03:06:15 -0600
committerCraig Jennings <c@cjennings.net>2025-11-17 03:06:15 -0600
commit200f7ca2d6621a7173ee73bc8e9111a5fde2c07d (patch)
treea7da8be8a03151ddb6c9d3d5913fcb2153b89376
parent0afa3fba94157d5e18f9a086e0b67b7cfd2aedf0 (diff)
feat(calendar-sync): Add auto-start toggle and convert to defvar
Changes: 1. Converted defcustom → defvar (3 variables): - calendar-sync-ics-url - calendar-sync-interval - calendar-sync-file - Removed defgroup (not using customize system) 2. Added calendar-sync-auto-start variable (default: t) - Controls whether auto-sync starts when module loads - Set to nil to disable automatic startup 3. Updated initialization to check auto-start flag - Auto-sync only starts if both auto-start and URL are non-nil - Provides user control over automatic behavior Rationale: - Auto-sync is convenient but should be toggleable - defvar is simpler and more direct than defcustom - Consistent with project style (no customize interface) Default behavior: Auto-sync enabled (backwards compatible with user expectation) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
-rw-r--r--modules/calendar-sync.el37
1 files changed, 17 insertions, 20 deletions
diff --git a/modules/calendar-sync.el b/modules/calendar-sync.el
index feb7188d..344b85c5 100644
--- a/modules/calendar-sync.el
+++ b/modules/calendar-sync.el
@@ -42,30 +42,22 @@
;;; Configuration
-(defgroup calendar-sync nil
- "Simple Google Calendar sync via .ics."
- :group 'calendar
- :prefix "calendar-sync-")
-
-(defcustom calendar-sync-ics-url nil
+(defvar calendar-sync-ics-url nil
"Google Calendar private .ics URL.
-Get this from Google Calendar Settings → Integrate calendar → Secret address in iCal format."
- :type '(choice (const :tag "Not configured" nil)
- (string :tag "iCal URL"))
- :group 'calendar-sync)
+Get this from Google Calendar Settings → Integrate calendar → Secret address in iCal format.")
-(defcustom calendar-sync-interval (* 15 60)
+(defvar calendar-sync-interval (* 15 60)
"Sync interval in seconds.
-Default: 15 minutes (900 seconds)."
- :type 'integer
- :group 'calendar-sync)
+Default: 15 minutes (900 seconds).")
-(defcustom calendar-sync-file
- gcal-file
+(defvar calendar-sync-file gcal-file
"Location of synced calendar file.
-Defaults to gcal-file from user-constants."
- :type 'file
- :group 'calendar-sync)
+Defaults to gcal-file from user-constants.")
+
+(defvar calendar-sync-auto-start t
+ "Whether to automatically start calendar sync when module loads.
+If non-nil, sync starts automatically when calendar-sync is loaded.
+If nil, user must manually call `calendar-sync-start'.")
;;; Internal state
@@ -443,10 +435,15 @@ Syncs immediately, then every `calendar-sync-interval' seconds."
(calendar-sync--current-timezone-offset))))
(message "calendar-sync: Timezone changed since last session (%s → %s)"
old-tz new-tz)
- (message "calendar-sync: Run `calendar-sync-now' or start auto-sync to update")
+ (message "calendar-sync: Will sync on next timer tick")
;; Note: We don't auto-sync here to avoid blocking Emacs startup
;; User can manually sync or it will happen on next timer tick if auto-sync is enabled
))
+;; Start auto-sync if enabled and URL is configured
+;; Syncs immediately then every calendar-sync-interval (default: 15 minutes)
+(when (and calendar-sync-auto-start calendar-sync-ics-url)
+ (calendar-sync-start))
+
(provide 'calendar-sync)
;;; calendar-sync.el ends here