Devigner blog about development and design

Applescript to Send Safari Url to Emacs Org-Mode

I’ve been a long time OmniFocus user and am a daily (or habitual) emacs user so it only makes sense for me to dabble with org mode for a GTD system. After all, when I’m writing code, why not have my projects todo lists in the next window. So this morning I figured I’d give org mode a try. It’s not polished like OmniFocus or Things but seriously; why does a todo list need satin pajamas? I’m not sure I’ll stick with it but I at least need to give it a trial run for a week or two.

How I Roll
When I get an email from a client that needs attention I use the clipper that comes with OmniFocus (Clip-o-tron 3000) to create a new task with a link to the email embedded. I also like to send research urls from Safari for projects to my todo lists as notes. This helps keep me on top of things (if that’s possible) as projects progress.

The Immediate Problem; No Clip-O-Tron
Since org-mode is basically a text file displayed within emacs, I need a way to send these to my org-mode file. I’m using gmail these days (trying to) and gmail has unique addresses for each email. All I need is to capture that url and send to org-mode.

Applescript to the rescue!
I wrote this applescript today that will capture the url from the foremost Safari window and save it to my org-mode file where I keep a “Inbox” at the very bottom of my file. Before saving the link I have it prompt me for a title for the link so that I can name it something meaningful. After it saves it to the end of my file, I get a growl notification telling me it’s done.

The AppleScript

To use this effectively, change the line 19 which reads set theFilePath to "Macintosh HD:Users:greg:gtd:" & "greg.org" as string to the path where your org file is located. I also keep my “Inbox” at the bottom of my org file so that when these new urls are saved, they are appended to the bottom of the inbox.

If you can’t get the script from this page, you can grab it over at Snipt here: http://snipt.net/gregnewman/send-safari-url-to-emacs-org-mode

If you use this script and find it useful, leave a comment and let me know about it. If you have ways to make it better, I’d love to see your changes.