From: Russell Adams <RLAdams@AdamsInfoServ.Com>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Ical import in Emacs 27.1 core packages
Date: Thu, 13 Aug 2020 15:45:38 +0200 [thread overview]
Message-ID: <20200813134538.GA19268@maokai> (raw)
Hello Org-ers!
I've just upgraded to Emacs 27.1 and the latest Org
(9.3.7-18-g093b47-elpa). While reviewing my init.el I found I was
still depending on org-import-icalendar.el to import ics files.
The link on Worg for this file is broken, and I could not find a good
source. It's not in ELPA or MELPA, so I felt it was a dead end.
Instead I discovered that Emacs Gnus already has an icalendar importer
which includes some Org functions! I'm not sure when they were
introduced, but I wanted to share because it's a built-in.
In my init.el:
#+begin_src lisp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Ical
;; Import ical files
(require 'gnus-icalendar)
(add-to-list 'org-capture-templates
'("#" "Ical capture target" plain
(file "~/doc/OrgFiles/Agenda.org")
"%i"
:immediate-finish t :empty-lines 1))
(setq gnus-icalendar-org-template-key "#")
(defun rla-import-ical-to-org-capture (filename)
(with-temp-buffer
(insert-file-contents filename)
(gnus-icalendar:org-event-save
(gnus-icalendar-event-from-buffer (current-buffer))
nil)))
#+end_src
The key is to have a predefined org-capture template created for
Gnus. There is a function to create one for you, but I preferred to
make one by hand which is just a plain Org file with each new event
appended to the end of the file. The Agenda.org file is also in my
agenda list.
Then I added a simple wrapper function to import an external file into
a buffer for Gnus to save to Org. I think Gnus called it with a buffer
which already contained the ical attachment from the mail message it
was currently viewing.
Now in Mutt if I receive a calendar invite, I can use mailcap to
import it into Org.
#+begin_src text
text/calendar; emacsclient -e '(rla-import-ical-to-org-capture "%s")' ; copiousoutput
application/ics; emacsclient -e '(rla-import-ical-to-org-capture "%s")' ; copiousoutput
#+end_src
Please let me know if this works for anyone else. It may be worth
documenting on Worg.
------------------------------------------------------------------
Russell Adams RLAdams@AdamsInfoServ.com
PGP Key ID: 0x1160DCB3 http://www.adamsinfoserv.com/
Fingerprint: 1723 D8CA 4280 1EC9 557F 66E8 1154 E018 1160 DCB3
reply other threads:[~2020-08-13 13:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200813134538.GA19268@maokai \
--to=rladams@adamsinfoserv.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.