diff --git a/config.el b/config.el index e4411af..73a326d 100644 --- a/config.el +++ b/config.el @@ -1775,6 +1775,29 @@ current frame." (setq org-caldav-delete-org-entries 'never) (setq org-caldav-delete-calendar-entries 'never) + ;; Fix #1: Baikal stores .ics files with literal @ in filename. + ;; org-caldav-get-event uses url-hexify-string which encodes @ as %40 → HTTP 404. + ;; UIDs like ...@google.com are stored on disk as literal @, so we must not encode it. + (defadvice org-caldav-get-event (around fix-at-encoding-in-uid + (uid &optional with-headers) activate) + "Preserve @ in UID path for Baikal CalDAV compatibility." + (cl-letf* ((orig-hexify (symbol-function 'url-hexify-string)) + ((symbol-function 'url-hexify-string) + (lambda (str) + (replace-regexp-in-string "%40" "@" (funcall orig-hexify str))))) + ad-do-it)) + + ;; Fix #2: Some CalDAV events have nil SUMMARY or missing fields, causing + ;; Wrong type argument: stringp, nil inside org-caldav-update-events-in-org. + ;; This advice catches the error and logs it so sync continues to save state. + (defadvice org-caldav-update-events-in-org (around skip-nil-field-events activate) + "Catch nil-field errors from malformed events; log and continue." + (condition-case err + ad-do-it + (wrong-type-argument + (message "org-caldav: skipped event with nil field: %S" err) + (org-caldav-debug-print 1 (format "Skipped nil-field event: %S" err))))) + (defun my/org-caldav-sync () "Sync 3 CalDAV kalendářů: 1. Osobni-Suky (default): stahuj vše → caldav-suky.org, nahraj jen calendar_outbox.org