emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kai Ma <justksqsf@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Find-file using org-protocol
Date: Wed, 15 Mar 2023 11:41:41 +0800	[thread overview]
Message-ID: <CFBCD904-3D30-4320-9F79-092C587B4AD0@gmail.com> (raw)

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	other threads:[~2023-03-15 12:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-15  3:41 Kai Ma [this message]
2023-03-15 14:09 ` Find-file using org-protocol Max Nikulin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CFBCD904-3D30-4320-9F79-092C587B4AD0@gmail.com \
    --to=justksqsf@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).