diff options
| author | Craig Jennings <c@cjennings.net> | 2025-10-29 09:00:57 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2025-10-29 09:00:57 -0500 |
| commit | 23757c45c43ebd7d721fefde4d9ddd74deac9814 (patch) | |
| tree | 54f894081ed9f796b3c9eabcc0c2ad9fcb43b78b /modules | |
| parent | af672b4a8a9bf5c2b89813d34be1d14a23969abf (diff) | |
| download | dotemacs-23757c45c43ebd7d721fefde4d9ddd74deac9814.tar.gz dotemacs-23757c45c43ebd7d721fefde4d9ddd74deac9814.zip | |
feat:org-gcal: Auto-save files after sync completion
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.el | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/modules/org-gcal-config.el b/modules/org-gcal-config.el index b3c636630..0c309a0ef 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 |
