13.7 iCalendar

When Gnus’ article-mode is chosen (The message view), it is possible to view and reply to iCalendar events. To enable this feature, add

(require 'mu4e-icalendar)

to your configuration. If you want that the original invitation message be automatically trashed after sending the message created by clicking on the buttons “Accept”, “Tentative”, or “Decline”, also add:

(setq mu4e-icalendar-trash-after-reply t)

When you reply to an iCal event, a line may be automatically added to the diary file of your choice. You can specify that file with

(setq mu4e-icalendar-diary-file "/path/to/your/diary")

Note that, if the specified file is not your main diary file, add #include "/path/to/your/diary" to you main diary file to display the events.

To enable optional iCalendar→Org sync functionality, add the following:

(setq gnus-icalendar-org-capture-file "~/org/notes.org")
(setq gnus-icalendar-org-capture-headline '("Calendar"))

Both the capture file and the headline(s) inside it must already exist.

By default, gnus-icalendar-org-setup adds a temporary capture template to the variable org-capture-templates, with the description “used by gnus-icalendar-org”, and the shortcut key “#”. If you want to use your own template, create it using the same key and description. This will prevent the temporary one from being installed next time you gnus-icalendar-org-setup is called.

The full default capture template is:

("#" "used by gnus-icalendar-org" entry
   (file+olp ,gnus-icalendar-org-capture-file
   "%i" :immediate-finish t)

where the values of the variables gnus-icalendar-org-capture-file and gnus-icalendar-org-capture-headline are inserted via macro expansion.

If, for example, you wanted to store ical events in a date tree, prompting for the date, you could use the following:

("#" "used by gnus-icalendar-org" entry
   (file+olp+datetree path-to-capture-file)
   "%i" :immediate-finish t :time-prompt t)

Note that the default behaviour for datetree targets in this situation is to store the event at the date that you capture it, not at the date that it is scheduled. That’s why I’ve suggested using the :timeprompt t argument. This gives you an opportunity to set the time to the correct value yourself.

You can extract the event time directly, and have the org-capture functions use that to set the datetree location:

(defun my-catch-event-time (orig-fun &rest args)
  "Set org-overriding-default-time to the start time of the capture event"
  (let ((org-overriding-default-time (date-to-time
                                      (gnus-icalendar-event:start (car args)))))
    (apply orig-fun args)))

(advice-add 'gnus-icalendar:org-event-save :around #'my-catch-event-time)

If you do this, you’ll want to omit the :timeprompt t setting from your capture template.