From cc594fdd28f2b047be25b6f016c7f47d23e741ec Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 4 May 2026 00:00:00 -0500 Subject: Make calendar sync startup safe without config --- modules/calendar-sync.el | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'modules/calendar-sync.el') diff --git a/modules/calendar-sync.el b/modules/calendar-sync.el index 06bee213..b232567a 100644 --- a/modules/calendar-sync.el +++ b/modules/calendar-sync.el @@ -69,10 +69,12 @@ ;;; Code: -(require 'user-constants) ; For gcal-file, pcal-file paths - ;;; Configuration +(defgroup calendar-sync nil + "One-way calendar synchronization to Org files." + :group 'calendar) + (defvar calendar-sync-calendars nil "List of calendars to sync. Each calendar is a plist with the following keys: @@ -89,17 +91,13 @@ Example: :url \"https://calendar.proton.me/api/calendar/v1/url/.../calendar.ics\" :file pcal-file)))") -;; Calendar sync (one-way: Google/Proton → Org) -(setq calendar-sync-calendars - `((:name "google" - :url "https://calendar.google.com/calendar/ical/craigmartinjennings%40gmail.com/private-1dad154d6a2100e755f76e2d0502f6aa/basic.ics" - :file ,gcal-file) - (:name "proton" - :url "https://calendar.proton.me/api/calendar/v1/url/MpLtuwsUNoygyA_60GvJE5cz0hbREbrAPBEJoWDRpFEstnmzmEMDb7sjLzkY8kbkF10A7Be3wGKB1-vqaLf-pw==/calendar.ics?CacheKey=LrB9NG5Vfqp5p2sy90H13g%3D%3D&PassphraseKey=sURqFfACPM21d6AXSeaEXYCruimvSb8t0ce1vuxRAXk%3D" - :file ,pcal-file) - (:name "deepsat" - :url "https://calendar.google.com/calendar/ical/craig.jennings%40deepsat.com/private-f0250a2c6752a5ca71d7b0636587a6d5/basic.ics" - :file ,dcal-file))) +(defcustom calendar-sync-private-config-file + (expand-file-name "calendar-sync.local.el" user-emacs-directory) + "Private calendar-sync config file loaded when readable. +This file is the intended place to set `calendar-sync-calendars' with private +calendar feed URLs." + :type 'file + :group 'calendar-sync) (defvar calendar-sync-interval-minutes 60 "Sync interval in minutes. @@ -1229,6 +1227,16 @@ Creates parent directories if needed." ;;; Debug Logging +(defun calendar-sync--load-private-config () + "Load private calendar-sync configuration when available." + (when (file-readable-p calendar-sync-private-config-file) + (condition-case err + (load calendar-sync-private-config-file nil t) + (error + (message "calendar-sync: Failed to load private config %s: %s" + (abbreviate-file-name calendar-sync-private-config-file) + (error-message-string err)))))) + (defun calendar-sync--debug-p () "Return non-nil if calendar-sync debug logging is enabled. Checks `cj/debug-modules' for symbol `calendar-sync' or t (all)." @@ -1446,6 +1454,8 @@ Syncs all calendars immediately, then every `calendar-sync-interval-minutes'." ;;; Initialization +(calendar-sync--load-private-config) + ;; Load saved state from previous session (calendar-sync--load-state) @@ -1465,7 +1475,9 @@ Syncs all calendars immediately, then every `calendar-sync-interval-minutes'." ;; Start auto-sync if enabled and calendars are configured ;; Syncs immediately then every calendar-sync-interval-minutes (default: 60 minutes) -(when (and calendar-sync-auto-start calendar-sync-calendars) +(when (and calendar-sync-auto-start + calendar-sync-calendars + (not noninteractive)) (calendar-sync-start)) (provide 'calendar-sync) -- cgit v1.2.3