After decades of using vi and Vim I switched to Spacemacs which is an amazing vi keystroke emulation layer running on Emacs and configured with an amazing set of preconfigured layers for different tasks. I decided to give it a try after seeing Org-Mode in action and seeing it was a nice taking system with integrations with almost anything imaginable. A few weeks ago I found out about org-protocol and followed this post by Jethro on using a bookmarket to capture from the Web to Emacs.
This page assumes a few things
- You use Emacs on a Mac
- You are using org and understand how to use capture and capture templates.
- You need to yank text from random apps into Emacs
Creating Automator Action
Start Automator. It's this icon. I'm guessing many people have had this for years and have never used it.
Open it and pick Quick Action
Grab the following text:
data="$@"
encoded=$(python -c "import sys, urllib; print urllib.quote(' '.join(sys.argv[1:]), safe='')" "${data[@]}")
emacsclient "org-protocol://capture?template=g&body=$encoded"
I borrowed some of it from this stack overflow question.
You want to head over to "Utilities" and drag over the "Run Shell Script" block. It should look like this:
Save it. You can confirm by checking the installed extensions in System Preferences. I named my test copy "test foo" and then created AddToEmacs as the permanent name.
Verify Action
Configure Emacs
In Emacs, open your init file. If you aren't using org-protocol, you'll need to install it with M-x package-install and add this:
Add this to your org-capture-templates section. I am using g for "Grab"
"* %? \n%i\n" :prepend t :created t )
Comments
Post a Comment