Download
(require 'gnus)
(defun send-invite-to-ical ()
"Write vcal event in current buffer to extract-ical-invite-file"
(interactive)
(save-excursion
(let (invite i-beg i-end
(content-buf (current-buffer))
(invite-file (make-temp-file (expand-file-name "send-invite-to-ical" temporary-file-directory) nil ".ics")))
(goto-char (point-min))
(if (not (re-search-forward "^BEGIN:VCALENDAR" (point-max) t))
(message "Didn't find BEGIN:VCALENDAR, stopping")
(setq i-beg (match-beginning 0))
(message "found match at %d" i-beg))
(setq i-end (re-search-forward "^END:VCALENDAR\n?" (point-max) t))
(if (not i-end)
(message "Didn't find END:VCALENDAR, stopping"))
(write-region i-beg i-end invite-file nil nil nil nil)
(shell-command (format "open %s" invite-file)))))
(defun send-invite-to-ical-from-gnus ()
(interactive)
(save-excursion
(when (equal major-mode 'gnus-article-mode)
(gnus-article-show-summary))
(when (equal major-mode 'gnus-summary-mode)
(gnus-summary-show-article)
(gnus-summary-select-article-buffer)
(gnus-mime-view-all-parts)
(send-invite-to-ical)
(gnus-summary-show-article))))
(defun extract-ical-gnus-insinuate ()
"Call this in your init file and you will be able to use 'C-c i'
to import an icalendar event into iCal"
(eval-after-load 'gnus-sum
`(define-key gnus-summary-mode-map ,(kbd "C-c i")
'send-invite-to-ical-from-gnus))
(eval-after-load 'gnus
`(define-key gnus-article-mode-map ,(kbd "C-c i")
'send-invite-to-ical-from-gnus)))
(provide 'extract-ical)