85

Mac For Translators: Capture (really) everywhere

 6 years ago
source link: https://mac4translators.blogspot.jp/2017/11/capture-really-everywhere.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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
try
tell application "System Events" to tell process "Emacs" to set frontmost to true
on error
tell application "/Path/to/Emacs.app"
activate
delay 2
end tell
end try
tell application "/Path/to/Emacs.app"
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!

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK