I use org-icalendar-export-to-ics to export org-agenda scheduled tasks to iCal format, which works nicely. In my use case, I always select export the "current file" (as opposed to "combine all agenda files").

This has the effect of creating an .ics file with a name like foo.ics. I then have to go navigate in Finder to go find that file and then open it in iCal.

How can I direct Emacs to open or open-with that .ics file automatically upon org-icalendar-export-to-ics? I can't imagine a scenario where I would want to export to an .ics file but not go on to open the .ics file and import the task into iCal.

Maybe some bash scripting around org-after-save-iCalendar-file-hook? The documentation for org-after-save-iCalendar-file-hook says "A good way to use this is to tell a desktop calendar application to re-read the iCalendar file," but it doesn't say how to go about telling my desktop calendar to do that.

  • 1
    How about? (defun test-fn (file) (start-process "my-process" nil "open" "-a" "/Applications/iCal.app" file)) (add-hook 'org-after-save-iCalendar-file-hook 'test-fn)
    – lawlist
    Nov 16, 2016 at 17:37
  • @lawlist Thanks! Doesn't work yet. Do we need to specify the file in the hook somehow? Nov 16, 2016 at 18:29
  • 1
    Can we please clarify the name of the hook -- the hook specified in your question is different than the one I see here: orgmode.org/w/?p=org-mode.git;a=blob_plain;f=lisp/… In the code that I linked to, the hook is named org-icalendar-after-save-hook. Once we get the name of the hook correct, you can start with a simple test to just generate a message in the *Messages* buffer: (defun test-fn (file) (message "This is the name of the file: %s" file)) (add-hook 'org-icalendar-after-save-hook 'test-fn) Then, adjust the name of the hook in the first comment.
    – lawlist
    Nov 16, 2016 at 18:38
  • @lawlist You were right, that was the problem. I modified a couple other things, this code now works: (defun org-icalendar-open-ics-file (file) (start-process "org-icalendar-open-ics-file-process" nil "open" "-a" "/Applications/Calendar.app" file)) (add-hook 'org-icalendar-after-save-hook 'org-icalendar-open-ics-file) Nov 16, 2016 at 18:46
  • 1
    Yes, newer versions of OSX have renamed iCal to Calendar -- I'm glad we got it all sorted out.
    – lawlist
    Nov 16, 2016 at 18:47

1 Answer 1


In conjunction with the assistance of the original poster in the comments above, here is the final solution:

(defun org-icalendar-open-ics-file (file)
  (start-process "org-icalendar-open-ics-file-process" nil "open" "-a" "/Applications/Calendar.app" file))

(add-hook 'org-icalendar-after-save-hook 'org-icalendar-open-ics-file) 
  • When I use org-icalendar-combine-agenda-files, the created ics should open correct? it is not working on my end. Nothing happens. Just the ics gets created.
    – Adelita
    Feb 15, 2023 at 22:08
  • 1
    @Adelita -- I don't have access to a modern version of MacOS .. the newest I have is El Capitan on one laptop. This question/answer is from the year 2016 ... things may have changed on newer versions of the OS and the aspect of org-mode that is related to this issue may also have been updated since then.
    – lawlist
    Feb 16, 2023 at 0:31
  • Fair point. thanks for your asnwer.
    – Adelita
    Feb 16, 2023 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.