diff --git a/init.d/text/misc.el b/init.d/text/misc.el index b5021b4..07842c6 100644 --- a/init.d/text/misc.el +++ b/init.d/text/misc.el @@ -112,7 +112,9 @@ :custom ((org-default-notes-file "~/notes.org") (org-startup-folded nil) (org-latex-compiler "xelatex") - (org-agenda-files '("~/notes.org" "~/Dokumente/Videoserien.org")) + (org-agenda-files '("~/notes.org" + "~/Dokumente/Videoserien.org" + "~/.calendars/org/tastytea_calendar.org")) (org-blank-before-new-entry '((heading . nil) (plain-list-item . auto))) (org-agenda-show-all-dates nil) @@ -215,5 +217,48 @@ (use-package json-mode) +;; Sync with CalDAV +(use-package org-caldav + :defer t + :custom ((org-caldav-url "https://buzuk.tastytea.de/caldav.php/tastytea") + (org-caldav-calendar-id "calendar") + (org-caldav-inbox "~/.calendars/org/tastytea_calendar.org") + (org-icalendar-timezone "Europe/Berlin") + (org-caldav-files nil)) + ;; + :config (defun org-caldav-url-dav-get-properties (url property) + "Retrieve PROPERTY from URL. + Output is the same as `url-dav-get-properties'. This switches to + OAuth2 if necessary." + (let ((request-data (concat "\n" "\n" "<" property "/>\n")) + (extra '(("Depth" . "1") ("Content-type" . "text/xml")))) + (let ((resultbuf (org-caldav-url-retrieve-synchronously + url "PROPFIND" request-data extra))) + (with-current-buffer resultbuf + (goto-char (point-min)) + (when (not (re-search-forward "^HTTP[^ ]* \\([0-9]+ .*\\)$" + (point-at-eol) t)) + (switch-to-buffer buffer) + (error "No valid HTTP response from URL %s." url)) + (let ((response (match-string 1))) + (when (not (string-match "2[0-9][0-9].*" response)) + (switch-to-buffer resultbuf) + (error "Error while doing PROPFIND for '%s' at URL %s: %s" property url response)))) + (org-caldav-namespace-bug-workaround resultbuf) + ;; HACK: remove DAV:responses with empty properties + (with-current-buffer resultbuf + (save-excursion + (while (re-search-forward "" nil t) + (let ((begin (point)) + (end (progn (re-search-forward "" nil t) (+ (point) 0)))) + (when (and begin end) + (goto-char begin) + (if (and (re-search-forward "" nil t) (< (point) end)) + (progn + (goto-char end) + (delete-region begin end)) + (goto-char end))))))) + (url-dav-process-response resultbuf url))))) + (provide 'text/misc) ;;; misc.el ends here