In the daily life, I prefer to use emacs org mode to manage my time and I also use iphone and macbook. The org mode is a perfect way to manage your time but iphone and calendar is a good way to track your time. So is there a good way to let them work better for me?

I tried org mobile before, but it is really hard to use in iphone , and it will create some mark line in the pushed event which make the org file more hard to read. I also tryed org-mac-ical.el but it is out of date and it can not work in OSX 10.10 now.

There is no good solution on the Internet. So one year ago, I made a perl script to parse the org file and import events into Calendar in OSX. Because it calls relative apple-script command to import events, it will work fine for further version of OSX without any changes.

It will automaticly import an event into osx calendar when you assigned a time to it. If your iphone is connected into cloud, it will of course alert your automaticly. And you can check your schedule on both org agenda and your iphone and clendar on the OSX.

The logic is simple:

1. When emacs store the org file in org mode or org agenda, call the script
2. The script will scan the org file and try to import the files into calendar one by one
3. When it finish scan it will store the added event time into time.txt
4. When any time is added, the event started with the same time will not be added

To use the script, you should added this script into your PATH and give it excutive right.

Added this line into your emacs setting files, there will add a hook and call the script every time you store any org file

(add-hook 'after-save-hook
       '(lambda ()
          ((if (or (eq major-mode 'org-mode) (eq major-mode 'org-agenda-mode))
                (progn
                  (setq org-add-event-command (concat "< " buffer-file-name))
                  (call-process-shell-command "_org_file_handler" nil nil nil org-add-event-command))))))

You should decide a way for the time.txt this will store all time stamp you already imported in the script

$time_file = "where/your/want/to/put/the/time.txt"

Most importantly, you should arrange your org file into this style, because this script will scan the * header as the calendar it want to insert the event:

* calendar name in osx calendar
** Other thing

For example, if I want to insert an event named: exercise into a calendar named life in osx calendar, I will make this even like below:

* life
** exercise
SCHEDULED: <2015-01-09 Fri 13:00-14:00>

Because it is a script I made almost 1 year ago and it works very well for me, there are some thing need to do better, but if there is no big problem, I won’t fix it, because maybe I will rewrite the script in Python in object oritential style. So if there are any interesting ideas to let me know?

A. The calendar have to restart to make the events be refreshed. (I think it is apple's problem)
B. time.txt maybe should be clean up, but it is not a big issue for us
C. I tell the application every time I want to add an event, I should be tell once and add many, but I am really lazy to change that. ^-^

I think it will work fine for you. enjoy!

Leave me a message

comments powered by Disqus

Published

Category

Programming

Tags