summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2025-10-29 09:00:57 -0500
committerCraig Jennings <c@cjennings.net>2025-10-29 09:00:57 -0500
commit980e21b9f0861c30ff4b371edf48c7f8bc1f1944 (patch)
tree4782976f851e65b47d1fe02a05f318928877e7ce /modules
parent43eb08a5b9b4f04ed94dd1684615b7ee6c66cd6c (diff)
feat:org-gcal: Auto-save files after sync completionHEADmain
Add a function to automatically save all org-gcal files after synchronization completes. This ensures that any changes are persisted, enhancing data consistency. Advise `org-gcal--sync-unlock` to trigger auto-saving upon sync completion.
Diffstat (limited to 'modules')
-rw-r--r--modules/org-gcal-config.el16
1 files changed, 15 insertions, 1 deletions
diff --git a/modules/org-gcal-config.el b/modules/org-gcal-config.el
index b3c63663..0c309a0e 100644
--- a/modules/org-gcal-config.el
+++ b/modules/org-gcal-config.el
@@ -109,7 +109,21 @@ enabling bidirectional sync so changes push back to Google Calendar."
(setq org-gcal-local-timezone (cj/detect-system-timezone))
;; Reload client credentials (should already be loaded by org-gcal, but ensure it's set)
- (org-gcal-reload-client-id-secret))
+ (org-gcal-reload-client-id-secret)
+
+ ;; Auto-save gcal files after sync completes
+ (defun cj/org-gcal-save-files-after-sync (&rest _)
+ "Save all org-gcal files after sync completes."
+ (dolist (entry org-gcal-fetch-file-alist)
+ (let* ((file (cdr entry))
+ (buffer (get-file-buffer file)))
+ (when (and buffer (buffer-modified-p buffer))
+ (with-current-buffer buffer
+ (save-buffer)
+ (message "Saved %s after org-gcal sync" (file-name-nondirectory file)))))))
+
+ ;; Advise org-gcal--sync-unlock which is called when sync completes
+ (advice-add 'org-gcal--sync-unlock :after #'cj/org-gcal-save-files-after-sync))
;; Set up automatic initial sync on boot with error handling
;;(run-with-idle-timer