Emacs on MacOS org-mode link handler for obsidian:// links

If you happen to be an Emacs user on MacOS AND want to be able to link to notes inside your obsidian vault inside of an org-mode document (who wouldn’t, right?), here’s some code for you. I use applescript as an intermediary because it works out of the box.

  ;; obsidan link handling for obsidian:// links
  (defun org-obidian-link-open (slash-message-id)
    "Handler for org-link-set-parameters that opens a obsidian:// link in obsidian"
    ;; remove any / at the start of slash-message-id to create real note-id
    (let ((message-id
           (replace-regexp-in-string (rx bos (* "/"))
       (concat "tell application \"Obsidian\" to open location \"obsidian://"
               "\" activate"))))
  ;; on obsdian://aoeu link, this will call handler with //aoeu
  (org-link-set-parameters "obsidian" :follow #'org-obidian-link-open)

include this after org is loaded in your private configuration

1 Like

I’m just look for the exact solution all around the internet, and you give me just the one I need. Thank you so much @hammond , wish you well. :+1:

1 Like