2

I am working on a Mac. I want to capture a link to a specific note within an org document that I can paste into another external application. In this case, I am using 'Things' (an external Mac OS X specific app) as my to-do list app, but capturing detailed notes in an org mode file. I would like Emacs to construct a URL that when clicked in 'Things' will take me to the precise note in Emacs.

Is this possible?

I have tried generating a link as per this question.

For example

[[file:~/Library/Mobile%20Documents/com~apple~CloudDocs/00%20meta/00.01%20deft/agenda.org::*my%20test%20note][my test note]]

And then manually editing the link to the following

file:///~/Library/Mobile%20Documents/com~apple~CloudDocs/00%20meta/00.01%20deft/agenda.org::*my%20test%20note

... but with no success. I suspect I will need to use another OS X scripting somehow, but I would like to know if anyone has some advice?

  • I use the org-id library to jump to a unique location in an org-mode file. Perhaps you can use an Applescript to active Emacs and then ... – lawlist Jul 4 at 16:41
  • @Drew an external Mac OS app: I've edited the qn to make this clear. Sorry – drstevok Jul 4 at 16:47
1

Mitsuharu Yamamoto's Emacs Mac Port supports org-protocol:// out of the box (the official Emacs doesn't, though you can set it up manually), for example, you can click the following link in other apps to store an org link into Emacs:

org-protocol://store-link?url=hello.py&title=hello-world-in-python

The Org Protocol is extensible, you can make it support open org link via org-protocol-protocol-alist. For example,

(setq org-protocol-protocol-alist
      '(("open-link"
         :protocol "open-link"
         :function chunyang-org-protocol-open-link)))

(defun chunyang-org-protocol-open-link (info)
  (with-temp-buffer
    (org-mode)
    (insert (format "[[%s]]" (plist-get info :url)))
    (backward-char)
    (org-open-at-point)))

then when you click this link in other apps, Emacs will open ~/play.org and move point to * Heading 1

org-protocol://open-link?url=file%3A~%2Fplay.org%3A%3A%2AHeading%25201

the above link is produced by

(format "org-protocol://open-link?url=%s"
        (url-hexify-string "file:~/play.org::*Heading%201"))
;; => "org-protocol://open-link?url=file%3A~%2Fplay.org%3A%3A%2AHeading%25201"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.