From mboxrd@z Thu Jan 1 00:00:00 1970 From: Allen Li Subject: Re: capture template placeholders do not work Date: Thu, 12 Oct 2017 14:12:00 -0700 Message-ID: References: <2E60E16B-A6A8-4D34-AE40-2933BF5F147D@me.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2kly-0000eQ-Ew for emacs-orgmode@gnu.org; Thu, 12 Oct 2017 17:12:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2klu-0007xp-DM for emacs-orgmode@gnu.org; Thu, 12 Oct 2017 17:12:06 -0400 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:49208) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2klu-0007xd-7s for emacs-orgmode@gnu.org; Thu, 12 Oct 2017 17:12:02 -0400 Received: by mail-qt0-x244.google.com with SMTP id k31so16113571qta.6 for ; Thu, 12 Oct 2017 14:12:02 -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: Kaushal Modi Cc: emacs-orgmode@gnu.org, Carl Bolduc On Thu, Oct 12, 2017 at 6:24 AM, Kaushal Modi wrote: > > 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) org-store-link-props basically shoves everything into org-store-link-plist (with some pre-processing). The plist keys are what's used as keywords for %: The :initlal is special; it gets mapped to %i, and :query is a list not a string, so you can't use %:query although you can access it from Emacs Lisp embedded in the template. I don't have any secret knowledge, I just dug through the source code and experimented with different inputs. The code and/or documentation could be clearer > > 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