1 #+TITLE: org-mac-iCal.el -- import Mac OS X iCal.app events into Emacs diary
2 #+OPTIONS: ^:{} author:nil
5 [[file:index.org][{Back to Worg's contibutions index}]]
7 If you find iCal.app the most convenient way to manage your diary, but
8 would still like to view your appointments in org agenda, then this
11 *N.B.* org-mac-iCal.el has only been tested on OS X 10.5. Apple's
12 handling of ics files changed between 10.4 and 10.5 to allow Spotlight
13 to index events. Unfortunately, the author no longer has access to
14 10.4 and 10.4 support is based entirely on his memory. The author
15 would welcome reports of success or failure of org-mac-iCal.el with OS
19 - To load org-mac-iCal.el by default:
21 : (add-to-list 'org-modules 'org-mac-iCal)
23 Note that =org-modules= must be set before org-mode is loaded.
25 - To view Emacs diary entries in the org agenda, ensure that
27 : (setq org-agenda-include-diary t)
32 =(org-mac-iCal)= will import all /checked/ iCal.app calendars into
33 your Emacs diary when called either interactively or as part of
36 *Warning: (org-mac-iCal) is destructive and will overwrite the
37 current contents of your Emacs diary.*
39 ** Customizable variables
40 - =org-mac-iCal-range= ::
42 Sets the number of months (default: 2) of events imported from
45 Because all-day and multi-day events are imported into the Emacs
46 diary as sexps, a large number of these can cause the Emacs
47 calendar view to slow down unacceptably. =org-mac-iCal-range=
48 sets how many months of events to import, /centred around the
49 current day/. Thus the default value of 2 imports events from one
50 month in the past to one month in the future.
53 The following code creates a custom command in the agenda
54 dispatcher to import iCal.app events and then display the agenda:
56 #+begin_src emacs-lisp
57 (setq org-agenda custom-commands
58 '(("I" "Import diary from iCal" agenda ""
59 ((org-agenda-mode-hook
64 A common problem with all-day and multi-day events in org agenda
65 view is that they become separated from timed events and are placed
66 below all =TODO= items. Likewise, additional fields such as
67 =Location:= are orphaned from their parent events. The following
68 hook will ensure that all events are correctly placed in the
71 #+begin_src emacs-lisp
72 (add-hook 'org-agenda-cleanup-fancy-diary-hook
74 (goto-char (point-min))
76 (while (re-search-forward "^[a-z]" nil t)
77 (goto-char (match-beginning 0))
78 (insert "0:00-24:00 ")))
79 (while (re-search-forward "^ [a-z]" nil t)
80 (goto-char (match-beginning 0))
82 (re-search-backward "^[0-9]+:[0-9]+-[0-9]+:[0-9]+ " nil t))
83 (insert (match-string 0)))))