Org-protocol
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.
For simplicity, let's start with the definition of org-roam-protocol-open-file.
(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.