about summary refs log tree commit diff stats
path: root/lisp/ical2org.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/ical2org.el')
-rw-r--r--lisp/ical2org.el56
1 files changed, 0 insertions, 56 deletions
diff --git a/lisp/ical2org.el b/lisp/ical2org.el deleted file mode 100644 index 2716787..0000000 --- a/lisp/ical2org.el +++ /dev/null
@@ -1,56 +0,0 @@
1;;; ical2org.el --- Run ical2org in Emacs -*- lexical-binding: t; -*-
2
3;;; Commentary:
4
5;; based on code from this reddit thread:
6;; https://www.reddit.com/r/emacs/comments/8s1ion/ical2org_integrations/
7;;
8;; see also: icalendar.org (converts to diary format, might be all I need)
9;;
10;; XXX: This code currently imports into gnus, which isn't what I want.
11
12;;; Code:
13
14(defun ical2org (&optional replace output-buffer)
15 "Run ical2org on contents of this buffer.
16If REPLACE (interactive prefix argument), replace contents of the
17buffer. If no REPLACE nor OUTPUT-BUFFER, output goes to
18minibuffer."
19 (interactive "P")
20 (shell-command-on-region (point-min) (point-max)
21 "ical2org"
22 output-buffer
23 replace
24 "*ical2org errors*"
25 'display-errors))
26
27(defun ical2org-capture ()
28 "Run `ical2org' on this buffer, then `org-capture' the result.
29Leaves current buffer as-was afterwards."
30 (interactive)
31 (let ((buf (current-buffer))
32 (ics (buffer-string)))
33 (ical2org 'replace)
34 (mark-whole-buffer)
35 (call-interactively #'org-capture)
36 (with-current-buffer buf
37 (delete-region (point-min) (point-max))
38 (insert ics))))
39
40(defun my-gnus-org-capture-icalendar ()
41 "Capture any text/calendar invites with org."
42 (interactive)
43 (with-current-buffer gnus-article-buffer ;;; XXX
44 (save-excursion
45 (dolist (part gnus-article-mime-handle-alist)
46 (when (and (>= (length part) 3)
47 (listp (caddr part))
48 (or (equal "application/ics" (caaddr part))
49 (equal "text/calendar" (caaddr part))))
50 (save-window-excursion
51 (gnus-mime-copy-part (cdr part))
52 (ical2org-capture)))))))
53(add-hook 'gnus-article-prepare-hook #'my-gnus-org-capture-icalendar)
54
55(provide 'ical2org)
56;;; ical2org.el ends here