From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Modi Subject: Re: capture template placeholders do not work Date: Thu, 12 Oct 2017 13:24:47 +0000 Message-ID: References: <2E60E16B-A6A8-4D34-AE40-2933BF5F147D@me.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="f403045f8c567c04bb055b59779f" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48900) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dTx-0004FX-7f for emacs-orgmode@gnu.org; Thu, 12 Oct 2017 09:25:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dTw-00044a-3P for emacs-orgmode@gnu.org; Thu, 12 Oct 2017 09:25:01 -0400 Received: from mail-lf0-x230.google.com ([2a00:1450:4010:c07::230]:55032) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dTv-00043p-OO for emacs-orgmode@gnu.org; Thu, 12 Oct 2017 09:25:00 -0400 Received: by mail-lf0-x230.google.com with SMTP id d10so5935084lfg.11 for ; Thu, 12 Oct 2017 06:24:59 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Allen Li , Carl Bolduc Cc: emacs-orgmode@gnu.org --f403045f8c567c04bb055b59779f Content-Type: text/plain; charset="UTF-8" On Thu, Oct 12, 2017 at 12:07 AM Allen Li wrote: > %:url and $:title are wrong, they should be %:link and %:description > respectively. > > Check out the source code of org-protocol-do-capture. > > The valid placeholders are > > type > link > description > annotation > I don't use org-protocol, but I'd just like to understand how you derived that. Source code: (defun org-protocol-do-capture (info) "Perform the actual capture based on INFO." (let* ((temp-parts (org-protocol-parse-parameters info)) (parts (cond ((and (listp info) (symbolp (car info))) info) ((= (length (car temp-parts)) 1) ;; First parameter is exactly one character long (org-protocol-assign-parameters temp-parts '(:template :url :title :body))) (t (org-protocol-assign-parameters temp-parts '(:url :title :body))))) (template (or (plist-get parts :template) org-protocol-default-template-key)) (url (and (plist-get parts :url) (org-protocol-sanitize-uri (plist-get parts :url)))) (type (and url (if (string-match "^\\([a-z]+\\):" url) (match-string 1 url)))) (title (or (plist-get parts :title) "")) (region (or (plist-get parts :body) "")) (orglink (if url (org-make-link-string url (if (string-match "[^[:space:]]" title) title url)) title)) (org-capture-link-is-already-stored t)) ;; avoid call to org-store-link (setq org-stored-links (cons (list url title) org-stored-links)) (org-store-link-props :type type :link url :description title :annotation orglink :initial region :query parts) (raise-frame) (funcall 'org-capture nil template))) >From that, we have: (org-store-link-props :type type :link url :description title :annotation orglink :initial region :query parts) but that is an internal call.. :link key gets its value from let-bound url and :description gets its value from let-bound title. And further up, url gets assigned value from a plist with key :url: (url (and (plist-get parts :url) (org-protocol-sanitize-uri (plist-get parts :url)))) and title gets assigned value from a plist with key :title. So that seems to match the documented: "The template refers to the data through %:url and %:title placeholders.". So I am surprised why %:link and %:description worked.. I didn't dig deeper as to where the connection with org-protocol and org-capture happens. -- Kaushal Modi --f403045f8c567c04bb055b59779f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Oct 12= , 2017 at 12:07 AM Allen Li <vianchielfaura@gmail.com> wrote:
%:url and $:title are wrong, they should be %:link and %:description<= br> respectively.

Check out the source code of org-protocol-do-capture.

The valid placeholders are

type
link
description
annotation

I don't use org-protocol= , but I'd just like to understand how you derived that.

<= /div>
Source code:

(defun org-protocol-do-capt= ure (info)
=C2=A0 "Perform the actual capture based on INFO.= "
=C2=A0 (let* ((temp-parts (org-protocol-parse-parameters i= nfo))
(parts
<= span style=3D"white-space:pre"> =C2=A0 (cond
=C2=A0 =C2=A0((and (listp info) (symbolp (car = info))) info)
=C2=A0 =C2= =A0((=3D (length (car temp-parts)) 1) ;; First parameter is exactly one cha= racter long
=C2=A0 =C2=A0= (org-protocol-assign-parameters temp-parts '(:template :url :title :bo= dy)))
=C2=A0 =C2=A0(t
=C2=A0 =C2=A0 (org-protocol-= assign-parameters temp-parts '(:url :title :body)))))
(template (or (plist-get parts :template)=
=C2=A0 =C2=A0 =C2=A0 = =C2=A0org-protocol-default-template-key))
(url (and (plist-get parts :url) (org-protocol-sanitize-u= ri (plist-get parts :url))))
(type (and url (if (string-match "^\\([a-z]+\\):" url)
=
=C2=A0 =C2=A0 (match-string = 1 url))))
(title (or (pl= ist-get parts :title) ""))
(region (or (plist-get parts :body) ""))
<= span style=3D"white-space:pre"> (orglink (if url
=C2=A0 =C2=A0 =C2=A0 (org-make-link-string=
=C2=A0 =C2=A0 =C2=A0 = =C2=A0url (if (string-match "[^[:space:]]" title) title url))
=C2=A0 =C2=A0 title))
=
(org-capture-link-is-already-= stored t)) ;; avoid call to org-store-link
=C2=A0 =C2=A0 (setq or= g-stored-links
=C2=A0 (co= ns (list url title) org-stored-links))
=C2=A0 =C2=A0 (org-store-l= ink-props :type type
= =C2=A0 :link url
=C2=A0= :description title
=C2= =A0 :annotation orglink
=C2=A0 :initial region
=C2=A0 :query parts)
=C2=A0 =C2=A0 (raise-frame)
=C2= =A0 =C2=A0 (funcall 'org-capture nil template)))=C2=A0

From that, we have:

(org-store-link-= props :type type
=C2=A0= :link url
=C2=A0 :desc= ription title
=C2=A0 :a= nnotation orglink
=C2= =A0 :initial region
=C2= =A0 :query parts)

but that is an internal ca= ll.. :link key gets its value from let-bound url and :description gets its = value from let-bound title.

And further up, url ge= ts assigned value from a plist with key :url:

=C2= =A0(url (and (plist-get parts :url) (org-protocol-sanitize-uri (plist-get p= arts :url))))

and title gets assigned value fr= om a plist with key :title.

So that seems to match= the documented: "The templa= te refers to the data through=C2=A0%:url=C2=A0and=C2=A0%:title=C2=A0placeholde= rs.".

So I am surprised why %:link and= %:description worked..

I didn't dig deeper as= to where the connection with org-protocol and org-capture happens.=C2=A0
--

Kaushal Modi

--f403045f8c567c04bb055b59779f--