emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* (org-protocol-check-filename-for-protocol) should not (server-edit)
@ 2014-12-11 16:19 Vladimir Alexiev
  0 siblings, 0 replies; only message in thread
From: Vladimir Alexiev @ 2014-12-11 16:19 UTC (permalink / raw)
  To: emacs-orgmode

I want org-protocol-store-link to paste the link in my current buffer and location, no questions asked.
I've defined a function like this:

(defun va/org-protocol-store-link (info)
  "Process an org-protocol://store-link:// style url.
Store a browser URL as an org link, automatically in the current buffer.
Also saves marked text. The browser bookmark has to look like this:
  javascript:location.href='org-protocol://store-link://'+ encodeURIComponent(location.href)+'/' \\ encodeURIComponent(document.title)+'/'+encodeURIComponent(window.getSelection())"
  (let* ((parts (org-protocol-split-data info t org-protocol-data-separator))
	 (url (org-protocol-sanitize-uri (car parts)))
	 (title (cadr parts))
	 (region (caddr parts)))
    ;; (set-buffer (car (buffer-list))) ; when called, a server buffer is current
    ;; (setq org-stored-links (cons (list uri title) org-stored-links))
    ;; (org-insert-link)
    (insert "[[" url "]")
    (if title (insert "[" title "]"))
    (insert "]")
    (if region (insert " " region))
    nil                                 ; no buffer to edit

And attached it like that:

(setq org-protocol-protocol-alist
      '(("org-store-link" :protocol "store-link"
         :function va/org-protocol-store-link :kill-client t)))

Unfortunately it pastes the link in the most recent "server" buffer.
The reason is that (org-protocol-check-filename-for-protocol) does (server-edit), 
which does "Switch to next server editing buffer; say "Done" for current buffer."

If I set the :kill-client to nil, nothing happens (as far as I can see).

Why does (org-protocol-check-filename-for-protocol) call (server-edit)?

Cheers! Vladimir

PS: the gmane search is pretty bad. I googled with this:
+"org-protocol" +"server-edit" url:gmane.emacs.orgmode
and found a slightly related article:

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-12-11 16:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-11 16:19 (org-protocol-check-filename-for-protocol) should not (server-edit) Vladimir Alexiev

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


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).