emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Find-file using org-protocol
@ 2023-03-15  3:41 Kai Ma
  2023-03-15 14:09 ` Max Nikulin
  0 siblings, 1 reply; 2+ messages in thread
From: Kai Ma @ 2023-03-15  3:41 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-15 14:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-15  3:41 Find-file using org-protocol Kai Ma
2023-03-15 14:09 ` Max Nikulin

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).