Displaying org-mode appointments in calendar

February 16, 2017

One neat feature of org-mode agenda is ability to display appointments in Emacs calendar. Sadly, this isn't obvious nor enabled by default - I discovered it accidentally by browsing through Emacs themes screenshots.

In screenshot below, you can see highlighted days with planned meetings and scheduled work in my calendar.

emacs-calendar

Setup is very easy. First, set calendar-mark-diary-entries-flag with:

(setq calendar-mark-diary-entries-flag t)

Then create $HOME/diary file, if not present, and add this line:

%%(org-diary)

Now in Emacs, open agenda view with (org-agenda) and open calendar with c; you will get highlighted all important dates. Alternatively, calling

M-x calendar

will essentially do the same (open calendar) with fewer strokes.

Reverse action will also work - to see what is scheduled for particular highlighted day, just point cursor to that day and hit key c - Emacs will open org-mode agenda view and place cursor under correct entry.

Using with appointments (appt)

In case you use org-mode with appointments to get visual reminders, be aware that calling (appt-activate 1) will run diary and making this call in your Emacs configuration will display diary window at Emacs startup, which I didn't like. To circumvent this behavior, appt-display-diary variable should be used.

In short, my appointments setup looks like this:

(add-hook 'org-finalize-agenda-hook
  (lambda ()
    (setq appt-message-warning-time 10        ;; warn 10 min in advance
          appt-display-diary nil              ;; do not display diary when (appt-activate) is called
          appt-display-mode-line t            ;; show in the modeline
          appt-display-format 'window         ;; display notification in window
          calendar-mark-diary-entries-flag t) ;; mark diary entries in calendar
    (org-agenda-to-appt)                      ;; copy all agenda schedule to appointments
    (appt-activate 1)))                       ;; active appt (appointment notification)