;; icalendar -> diary code (require 'icalendar) (require 'url) (defcustom egh:ical-diary-url-list '() "List of ICS urls and the diary files to convert them to. DIARY FILES WILL BE OVERWRITTEN!" :type '(repeat (cons string string))) (defun egh:remote-ics-to-diary (url diary) (let* ((ics-temp (make-temp-file "ical")) (curl-args (append (list "-o" ics-temp) (list url)))) (apply 'call-process "curl" nil nil nil curl-args) (with-temp-buffer (insert-file-contents ics-temp) (icalendar-import-buffer diary t)) (delete-file ics-temp) (save-excursion (find-file diary) (save-buffer) (kill-buffer nil)))) (defun egh:ical-import-all () (interactive) (let ((fetch-and-process-ical-url (lambda (entry) (let* ((url (car entry)) (file (expand-file-name (cdr entry))) (buff (get-file-buffer file))) (if buff (kill-buffer buff)) (if (file-exists-p file) (delete-file file)) (egh:remote-ics-to-diary url file))))) (mapc fetch-and-process-ical-url egh:ical-diary-url-list))) (add-hook 'diary-display-hook 'fancy-diary-display) (add-hook 'list-diary-entries-hook 'include-other-diary-files) (add-hook 'mark-diary-entries-hook 'mark-included-diary-files) (setq midnight-mode t) (add-hook 'midnight-hook 'egh:remote-ics-to-diary)