为实现这个帖子中的功能,
我研究了下 如何在macos上配置org-protocol,在chrome上测试成功
我用的是emacsclient,
配置步骤:
- run command below on terminal (打开脚本剪辑器):
open -a /System/Applications/Utilities/Script\ Editor.app
点击新建文稿
- copy content below in the Script Editor
on open location this_URL
do shell script "/usr/local/bin/emacsclient -s \"$HOME/.emacs.d/server/server1\" \"" & this_URL & "\""
end open location
Save it as Applications (存储为应用程序,not the default Script) File Format and create org-protocol.app under directory: /Applications
you will find info.plist under /Applications/org-protocol.app directory
- Open info.plist in org-protocol.app, the structure looks like this:
<plist>
<dict>
...
</dict>
</plist>
- Add CFBundleIdentifier snippet below as child of
<dict>
in info.plist
<key>CFBundleIdentifier</key>
<string>com.apple.ScriptEditor.id.org-protocol</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Org Protocol Handler</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>aplt</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>EmacsClientCapture</string>
<key>CFBundleURLSchemes</key>
<array>
<string>org-protocol</string>
</array>
</dict>
</array>
- To register the org-protocol, just double click on the org-protocol.app
- config org capture template
(add-to-list 'org-capture-templates
'("w" "Web Capture" entry
(file "/tmp/web-captures.org")
"* %^{Title}\n:PROPERTIES:\n:URL: %:link\n:END:\n\n%i\n%?"
:immediate-finish t
:kill-buffer t
:prepend t))
-
verify if shell script in org-protocol.app works by clicking bookmark on chrome which is a javascript
a) chrome will ask you if you want to open org-protocol.app
b) emacs also will have some action
c) 验证emacs, 我用的是emacsclient
emacsclient -s $HOME/.emacs.d/server/server1 "org-protocol://capture?template=w&url=https%3A%2F%2Forgmode.org%2Fworg%2Forg-contrib%2Forg-protocol.html%23org3f06679&title=org-protocol.el%20%E2%80%93%20Intercept%20calls%20from%20emacsclient%20to%20trigger%20custom%20actions&body=After%20installing%20EmacsClient.app%20you%20should%20then%20%5B%5Bhttps%3A%2F%2Forgmode.org%2Fworg%2Forg-contrib%2Forg-protocol.html%23org3f06679%5D%5BVerify%20the%20installation%5D%5D.%20Once%20verified%2C%20you%20can%20begin%20%5B%5Bhttps%3A%2F%2Forgmode.org%2Fworg%2Forg-contrib%2Forg-protocol.html%23orgf13b7a9%5D%5BUsing%20org-protocol%5D%5D"
参考文献: