Table of contents

Org-protocol

%3 cluster_e0214fa2_8beb_40c2_80fd_7579f7b5cf02 Org-protocol _e99e170c_b034_44b1_9971_6dcff56e0655 Using Emacs 70 - Org Protocol _38c7280a_de11_46a6_9557_b1e4830b8c1a How to use it _aa29be89_70e7_4465_91ed_361cf0ce62f2 Emacs _5baf5cef_5fad_446b_a56c_70e3b917ea4b With org-protocol _5baf5cef_5fad_446b_a56c_70e3b917ea4b->__0:cluster_e0214fa2_8beb_40c2_80fd_7579f7b5cf02 __1:cluster_e0214fa2_8beb_40c2_80fd_7579f7b5cf02->_aa29be89_70e7_4465_91ed_361cf0ce62f2

How to use it

  • Find available handlers

org-protocol-protocol-alist

  • For example, let's check org-protocol-open-source. To get it's information run

(describe-function 'org-protocol-open-source)

  • Note: "Process an org-protocol://open-source?url=" . That's the syntax

  • Let's define a handler to go to a org-id.

(defun org-roam-protocol-open-file (info)
           "This handler simply opens the file with emacsclient.
         INFO is an alist containing additional information passed by the protocol URL.
         It should contain the FILE key, pointing to the path of the file to open.
           Example protocol string:
         org-protocol://roam-file?file=/path/to/file.org"
           (when-let ((file (plist-get info :file)))
             (raise-frame)
             (org-roam--find-file file))
           nil)
  • Let's modify it to call org-id-goto

(defun org-protocol-open-id (info)
           "This handler simply opens the file with emacsclient.
                  INFO is an alist containing additional information passed by the protocol URL.
                  It should contain the id key, with the ID of the section to open.
                    Example protocol string:
                  org-protocol://org-id?id=1234-5678"
           (when-let ((id (plist-get info :id)))
             (raise-frame)
             (org-id-goto id))
           nil)

  • Then define the protocol call

(push '("org-id"  :protocol "org-id"   :function org-protocol-open-id)
               org-protocol-protocol-alist)

  • If you have correctly configured and navigate to org-protocol:/org-id?id=YOUR_ORG_ID/, the section should open on the org file.