all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: Allen Li <vianchielfaura@gmail.com>, Carl Bolduc <cbol@me.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: capture template placeholders do not work
Date: Thu, 12 Oct 2017 13:24:47 +0000	[thread overview]
Message-ID: <CAFyQvY3iz9n-ADj3Jsf6oH3D5MFkCT=Z6+B8CngozNWULVVGVg@mail.gmail.com> (raw)
In-Reply-To: <CAJr1M6cz-E3T=7a0HXasB6=EA25bdOeYd_nd1__LU8c2QKKhog@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2403 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 5476 bytes --]

  parent reply	other threads:[~2017-10-12 13:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-11 18:47 capture template placeholders do not work Carl Bolduc
2017-10-12  3:54 ` Allen Li
2017-10-12 12:27   ` Carl Bolduc
2017-10-12 13:24   ` Kaushal Modi [this message]
2017-10-12 21:12     ` Allen Li
2017-10-12 22:43       ` Kaushal Modi

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

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

  git send-email \
    --in-reply-to='CAFyQvY3iz9n-ADj3Jsf6oH3D5MFkCT=Z6+B8CngozNWULVVGVg@mail.gmail.com' \
    --to=kaushal.modi@gmail.com \
    --cc=cbol@me.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=vianchielfaura@gmail.com \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.