emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] capture template placeholders do not work


From: Kaushal Modi
Subject: Re: [O] capture template placeholders do not work
Date: Thu, 12 Oct 2017 13:24:47 +0000

On Thu, Oct 12, 2017 at 12:07 AM Allen Li <address@hidden> 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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]