Merge branch 'master' of ssh://repo.or.cz/srv/git/Worg
[Worg.git] / org-contrib / org-mac-iCal.org
blobd9b3eba5971fbde58060fa17af3140115ec99cab
1 #+TITLE:     org-mac-iCal.el -- import Mac OS X iCal.app events into Emacs diary
2 #+OPTIONS:   ^:{} author:nil
3 #+STARTUP: odd
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
9 module may help.
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
16 X 10.4 or earlier.
18 * Installation
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)
29     is set.
31 * Usage
32   =(org-mac-iCal)= will import all /checked/ iCal.app calendars into
33   your Emacs diary when called either interactively or as part of
34   another function.
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
43      iCal.app calendars.
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.
52 ** Examples of usage
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
60            (lambda ()
61              (org-mac-iCal)))))))
62 #+end_src
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
69    agenda:
71 #+begin_src emacs-lisp
72 (add-hook 'org-agenda-cleanup-fancy-diary-hook
73           (lambda ()
74             (goto-char (point-min))
75             (save-excursion
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))
81               (save-excursion
82                 (re-search-backward "^[0-9]+:[0-9]+-[0-9]+:[0-9]+ " nil t))
83               (insert (match-string 0)))))
84 #+end_src
86