emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Find-file using org-protocol


From: Kai Ma
Subject: Find-file using org-protocol
Date: Wed, 15 Mar 2023 11:41:41 +0800

Hi org

I’m using org-protocol to open local files in an Emacs client.  Yes, this is 
weird, but it is required for some Electron apps, because they do not allow 
calling arbitrary commands.

This is how I do it:

(use-package org-protocol
  :config
  (add-to-list 'org-protocol-protocol-alist
               '("org-find-file" :protocol "find-file" :function 
org-protocol-find-file :kill-client nil))

  (defun org-protocol-find-file (fname)
    "Process org-protocol://find-file?path= style URL."
    (let ((f (plist-get (org-protocol-parse-parameters fname nil '(:path)) 
:path)))
      (find-file f)
      (raise-frame)
      (select-frame-set-input-focus (selected-frame)))))

It works, but there’s a minor annoyance: the buffer it opens is not associated 
with the client.  And killing the client won’t kill the buffer it creates.

Upon some inspection, I find that org-protocol-check-filename-for-protocol 
seems to discard information about the client, so I cannot set 
server-buffer-clients and server-existing-buffer accordingly myself.

I’m writing to ask if there is a better way than advising server-visit-files or 
org-protocol-check-filename-for-protocol?

Thanks!

Regards,
Kai


reply via email to

[Prev in Thread] Current Thread [Next in Thread]