;;; ical2org.el --- Run ical2org in Emacs -*- lexical-binding: t; -*- ;;; Commentary: ;; based on code from this reddit thread: ;; https://www.reddit.com/r/emacs/comments/8s1ion/ical2org_integrations/ ;; ;; see also: icalendar.org (converts to diary format, might be all I need) ;; ;; XXX: This code currently imports into gnus, which isn't what I want. ;;; Code: (defun ical2org (&optional replace output-buffer) "Run ical2org on contents of this buffer. If REPLACE (interactive prefix argument), replace contents of the buffer. If no REPLACE nor OUTPUT-BUFFER, output goes to minibuffer." (interactive "P") (shell-command-on-region (point-min) (point-max) "ical2org" output-buffer replace "*ical2org errors*" 'display-errors)) (defun ical2org-capture () "Run `ical2org' on this buffer, then `org-capture' the result. Leaves current buffer as-was afterwards." (interactive) (let ((buf (current-buffer)) (ics (buffer-string))) (ical2org 'replace) (mark-whole-buffer) (call-interactively #'org-capture) (with-current-buffer buf (delete-region (point-min) (point-max)) (insert ics)))) (defun my-gnus-org-capture-icalendar () "Capture any text/calendar invites with org." (interactive) (with-current-buffer gnus-article-buffer ;;; XXX (save-excursion (dolist (part gnus-article-mime-handle-alist) (when (and (>= (length part) 3) (listp (caddr part)) (or (equal "application/ics" (caaddr part)) (equal "text/calendar" (caaddr part)))) (save-window-excursion (gnus-mime-copy-part (cdr part)) (ical2org-capture))))))) (add-hook 'gnus-article-prepare-hook #'my-gnus-org-capture-icalendar) (provide 'ical2org) ;;; ical2org.el ends here