diff options
author | Case Duckworth | 2023-05-10 13:08:35 -0500 |
---|---|---|
committer | Case Duckworth | 2023-05-10 13:08:35 -0500 |
commit | 43bed1f97e6f1a229553d7a25dc437741326772e (patch) | |
tree | 690012bd1a3797c41dff9b181f2e3ec44bd942ce /lisp/ical2org.el | |
parent | changes (diff) | |
download | emacs-43bed1f97e6f1a229553d7a25dc437741326772e.tar.gz emacs-43bed1f97e6f1a229553d7a25dc437741326772e.zip |
Bankruptcy 10
Diffstat (limited to 'lisp/ical2org.el')
-rw-r--r-- | lisp/ical2org.el | 56 |
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. | ||
16 | If REPLACE (interactive prefix argument), replace contents of the | ||
17 | buffer. If no REPLACE nor OUTPUT-BUFFER, output goes to | ||
18 | minibuffer." | ||
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. | ||
29 | Leaves 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 | ||