0

I want to create a URL that uses org-id to jump to its associated heading in Emacs org-mode.

I tried using:

org-protocol://org-id-goto?id=DC6BC674-8CE1-451D-A45F-05E09F1F743D

But this only opens Emacs with a blank *scratch* window. It does not actually navigate anywhere... am I missing something?

Also, I notice that each time I enter this link in my browser, I get a pop-up message, asking if I want to allow "Safari/Firefox/Chrome/Etc." to open Emacs. Is there anyway to disable this message for the future?

  • Read the "Usage" section at the beginning of org-protocol.el. Briefly, you need to start the emacs server in your emacs and use emacsclient to connect. Once that works, then you can try adding it to external applications. – NickD Feb 22 '19 at 11:58
  • @NickD I don't think we are talking about the same thing. I am looking to build a URL that will click through to a heading in an org document, regardless of what app you are using to click through. Railwaycats Emacs appears to already be setup with the org-protocol syntax. But for some reason is not responding to org-id-goto... – Adam Feb 22 '19 at 16:39
2

I'm doing the same thing as you under the inspiration of Roam Protocol

You can't use the built-in org-id-goto directly, you have to custom your own org-protocol handler first. Here's the way I do:

(add-to-list 'org-protocol-protocol-alist
             '("org-id" :protocol "org-id"
               :function org-id-protocol-goto-org-id))

(defun org-id-protocol-goto-org-id (info)
  "This handler simply goes to the org heading with given id using emacsclient.

    INFO is an alist containing additional information passed by the protocol URL.
    It should contain the id key, pointing to the path of the org id.

      Example protocol string:
      org-protocol://org-id?id=309A0509-81BE-4D51-87F4-D3F61B79EBA4"
  (when-let ((id (plist-get info :id)))
    (org-id-goto id))
  nil)

Then, if you open link like org-protocol://org-id?id=309A0509-81BE-4D51-87F4-D3F61B79EBA4 in a web brower, it will jump directly to the heading with id 309A0509-81BE-4D51-87F4-D3F61B79EBA4 in emacs.

Also, here's a snippet for getting this kind of org-protocol link from current heading:

(defun org-id-protocol-link-copy ()
  (interactive)
  (org-kill-new (concat "org-protocol://org-id?id="
                        (org-id-copy))))
| improve this answer | |

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.