33.10.7.2 Displaying iCalendar entries in the Diary

If you primarily store your calendar data outside of Emacs, but still want to see it in the Emacs calendar and diary, you can do so by including an iCalendar file from your diary file.

Suppose, for example, that you download your calendar from an external server to a file called Appointments.ics. Then you can include this file in your diary by writing a line like

#include "path/to/Appointments.ics"

in your diary file. You must also set up some hooks to display the data in that file as diary entries and mark them in the calendar:

(add-hook 'diary-mark-entries-hook
          #'diary-mark-included-diary-files)
(add-hook 'diary-nongregorian-marking-hook
          #'diary-icalendar-mark-entries)
(add-hook 'diary-list-entries-hook
          #'diary-include-other-diary-files)
(add-hook 'diary-nongregorian-listing-hook
          #'diary-icalendar-display-entries)

Events, tasks, and journal entries in Appointments.ics will then show up on the appropriate days when you display the diary from the calendar. See Displaying the Diary.

The advantage of doing this is that you don’t need to synchronize the data between the calendar server and your diary file. This is simpler and more reliable than regularly importing and exporting between diary and iCalendar format.

You can also display iCalendar attachments in email messages without importing them to your diary file using the function diary-icalendar-mailcap-viewer. You can add this function, for example, to the variable mailcap-user-mime-data; see its docstring for more information.

Displaying iCalendar entries uses the same infrastructure as importing them, so customizing the import format will also change the format of the displayed entries. See Importing iCalendar data as Diary Entries.