Capture (really) everywhere

Capturing thoughts is an excellent first step to organizing them. And Emacs provides one of the best organization solution in the computer world: org-mode.

When you work in Emacs all the time, you can capture your thoughts and sort them in org-mode from any place thanks to a global shortcut (C-c c by default). If you do not work in Emacs all the time, you can use various shortcuts to put Emacs front and hit C-c c to open a capture template.

My solution to accelerate the process is to use AppleScript to put Emacs in the front and type the capture template opening command.

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

tell application "System Events" to tell process "Emacs" to set frontmost to true
on error
tell application "/Path/to/"
delay 2
end tell
end try

tell application "/Path/to/"
tell application "System Events"
delay 0.1
keystroke "c" using {control down}
keystroke "c"
delay 0.1
end tell

end tell

I save the above code as an application, with a name I can readily call and that won't conflict with a commonly used word on my machine. I chose ">Capture".

Once the application is saved, calling it and launching it from Spotlight is trivial. The default shortcut for Spotlight is Command+Space. Then you start typing the first characters of your application name and when it appears, you hit Enter.

On my system I hit Ctrl+Space, then >C, and Spotlight shows >Capture. I hit Enter and Emacs comes to the front and has launched the capture template selector. I'm in Emacs now and I can do whatever I want there.

You may run into an issue where Emacs gets a different key even though you ordered AppleScript to hit C-c c. Emacs comes up with an error message like "C-s-268632079 is undefined". On my machine I had 2 such undefined "keys". The trivial solution is to add the keys to your .emacs.el file so that they are associated to org-capture:

(global-set-key (kbd "<C-s-268632079>") 'org-capture)
(global-set-key (kbd "<C-s-268632067>") 'org-capture)

Et voilĂ ! Go capture your thoughts now!