Giter VIP home page Giter VIP logo

setup-org-protocol-on-mac's Introduction

Setting Up org-protocol on Mac

org-protocol.el – Mac OS X setup doesn’t work anymore according to Issue #3 · neil-smithline-elisp/EmacsClient.app.

Step 1. Create an application

  • Launch the Script Editor application and create a new document
  • Copy-and-paste the following code into the new document
  • Change “/usr/local/bin/emacsclient” to path to emacsclient on your system
  • Save it in Application (not the default Script) File Format as org-protocol.app
on open location this_URL
	do shell script "/Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_14/emacsclient \"" & this_URL & "\""
	tell application "Emacs" to activate
end open location

Step 2. Configure the application

  • Navigate to the application (i.e., org-protocol.app) in the Finder, then right-click on it and select Show Package Contents. Now go into the Contents folder and open Info.plist
  • Add the following code to the file, making sure to keep all existing key/string pairs intact:
<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleURLName</key>
    <string>org-protocol handler</string>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>org-protocol</string>
    </array>
  </dict>
</array>

Step 3. Test your results

See http://orgmode.org/worg/org-contrib/org-protocol.html#orgheadline8

Notes

Emacs doesn’t activate?

I use graphical Emacs and start Emacs server from there, however after clicking some org-protocol link, Emacs doesn’t activate. I don’t know the cause. If you encounter the same issue AND don’t like it, you can try this instead

on open location this_URL
   do shell script "/usr/local/bin/emacsclient \"" & this_URL & "\" && open -a Emacs"
end open location

User Script

On web browser, besides bookmarklets, you can also use User Script, for example, ./org-protocol.user.js binds two keys to Org: store-link and Org: capture.

setup-org-protocol-on-mac's People

Contributors

xuchunyang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

setup-org-protocol-on-mac's Issues

About the mysterious difference between `open` from terminal and a browser like Chrome.

While this is not a direct issue with this repo itself, I think documenting this and being searchable here might help people to figure out what to do with this mysterious behaviour.


So things like below similar to the one from current README.md worked with open but not with Chrome for me.

on open location this_URL
	do shell script "emacsclient \"" & this_URL & "\" && open -a Emacs"
end open location

And if you debug this by something like below. You don't really see the difference yet.

on open location this_URL
	do shell script "echo '" & this_URL & "' >> ~/tmp/debug-org-protocol"
end open location

But if you pipe it via base64 you might see a strange difference especially with a long enough this_URL

Try org-protocol://find-file:///Users/my-user/my-folder/my-file with both open and Chrome.

# tail -f ~/tmp/debug-org-protocol

# with `open` - it results in 2 lines - I don't know why
b3JnLXByb3RvY29sOi8vZmluZC1maWxlOi8vL1VzZXJzL215LXVzZXIvbXktZm9sZGVyL215LWZp
bGUK
# with Chrome - it prints in one line - expected
b3JnLXByb3RvY29sOi8vZmluZC1maWxlOi8vL1VzZXJzL215LXVzZXIvbXktZm9sZGVyL215LWZpbGUK

However, if you wrap the whole script with zsh now the Chrome's behaviour follows the same as zsh and

on open location this_URL
	do shell script "zsh -c \"echo '" & this_URL & "' | base64 >> ~/tmp/debug-org-protocol\""
end open location
# with `open` - it stays the same
b3JnLXByb3RvY29sOi8vZmluZC1maWxlOi8vL1VzZXJzL215LXVzZXIvbXktZm9sZGVyL215LWZp
bGUK
# with Chrome - it follows `open` now
b3JnLXByb3RvY29sOi8vZmluZC1maWxlOi8vL1VzZXJzL215LXVzZXIvbXktZm9sZGVyL215LWZp
bGUK

Same goes for org-protocol and now it is being recognized with Chrome as well with a code like below.

on open location this_URL
	do shell script "zsh -c 'emacsclient \"" & this_URL & "\" && open -a Emacs'"
end open location

Also, if I used bash instead of zsh, it didn't work.

Hope this is helpful for some people!

Not working for MacOS M1 chip user

Hi thanks first for the repo. I was trying to setup the protocol early today but the script seems not working. I looked into the script and sort of guessed where the problem could be and fixed the problem. I don't know how to contribute to the repo but hopeful this tip can help other users who have non-programming background and are usually clueless when there's no existing working solution readily available on the internet:

Update for Macbook built on AMD chips. homebrew installs software to folder different from usr/bin, to find the actual location of the emacsclient, run brew info emacs to find the path of emacsclient and navigate into the file to get the file path of emacsclient, it's usually under bin folder. After finding the exact location, replace the path stated in the script section.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.