Function: org-protocol-store-link
org-protocol-store-link is a byte-compiled function defined in
org-protocol.el.gz.
Signature
(org-protocol-store-link FNAME)
Documentation
Process an org-protocol://store-link style url.
Additionally store a browser URL as an org link. Also pushes the
link's URL to the kill-ring.
Parameters: url, title (optional), body (optional)
Old-style links such as org-protocol://store-link://URL/TITLE are also recognized.
The location for a browser's bookmark may look like this:
javascript:location.href = 'org-protocol://store-link?' +
new URLSearchParams({url:location.href, title:document.title});
or to keep compatibility with Org versions from 9.0 to 9.4 it may be:
javascript:location.href = \
'org-protocol://store-link?url=' + \
encodeURIComponent(location.href) + '&title=' + \
encodeURIComponent(document.title);
Don't use escape()! Use encodeURIComponent() instead. The
title of the page could contain slashes and the location
definitely will. Org 9.4 and earlier could not decode "+"
to space, that is why less readable latter expression may be necessary
for backward compatibility.
The sub-protocol used to reach this function is set in
org-protocol-protocol-alist.
FNAME should be a property list. If not, an old-style link of the form URL/TITLE can also be used.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-protocol.el.gz
;;; Standard protocol handlers:
(defun org-protocol-store-link (fname)
"Process an org-protocol://store-link style url.
Additionally store a browser URL as an org link. Also pushes the
link's URL to the `kill-ring'.
Parameters: url, title (optional), body (optional)
Old-style links such as org-protocol://store-link://URL/TITLE are
also recognized.
The location for a browser's bookmark may look like this:
javascript:location.href = \\='org-protocol://store-link?\\=' +
new URLSearchParams({url:location.href, title:document.title});
or to keep compatibility with Org versions from 9.0 to 9.4 it may be:
javascript:location.href = \\
\\='org-protocol://store-link?url=\\=' + \\
encodeURIComponent(location.href) + \\='&title=\\=' + \\
encodeURIComponent(document.title);
Don't use `escape()'! Use `encodeURIComponent()' instead. The
title of the page could contain slashes and the location
definitely will. Org 9.4 and earlier could not decode \"+\"
to space, that is why less readable latter expression may be necessary
for backward compatibility.
The sub-protocol used to reach this function is set in
`org-protocol-protocol-alist'.
FNAME should be a property list. If not, an old-style link of the
form URL/TITLE can also be used."
(let* ((splitparts (org-protocol-parse-parameters fname nil '(:url :title)))
(uri (org-protocol-sanitize-uri (plist-get splitparts :url)))
(title (plist-get splitparts :title)))
(when (boundp 'org-stored-links)
(push (list uri title) org-stored-links))
(kill-new uri)
(message "`%s' to insert new Org link, `%s' to insert %S"
(substitute-command-keys "\\[org-insert-link]")
(substitute-command-keys "\\[yank]")
uri))
nil)