Richard Lawrence <[email protected]> writes:

>> The most appropriate existing mechanism to pass metadata into capture
>> template is org-store-link-plist. That's what org-protocol uses.
>> %:keyword in capture templates uses org-store-link-plist.
>>
>> However, actually passing the data through that plist requires binding
>> org-capture-link-is-already, which is a kludge introduced specifically
>> for this purpose. It is not the best design.
>> We should better allow a specialized variable like
>> org-capture-metadata-plist or similar that will be used in addition to
>> org-store-link-plist.
>>
>> Patches or better design ideas are welcome.
>
> A plist would suit my use case pretty well, and I think it would be hard
> to do much better.  It's a tricky problem because, on the one hand, it
> would be nice to have a way for Lisp programs to communicate arbitrary
> data to capture templates, but on the other hand, the whole point is to
> allow the user to customize the template, and therefore the Lisp program
> can't make any assumptions about how much of that data actually makes it
> into the filled template, and also can't assume that the user is willing
> to write any Elisp to get values out of it.

Well. We already separate `org-capture-plist'
and `org-store-link-plist'. The latter is used to expand %:keyword
specifically. It is also populated automatically (an unconditionally) by
org-store-link. Allowing override for this link-based plist makes sense,
and it is already done by org-capture, just using slightly awkward
implementation (org-capture-link-is-already-stored).

> My use case is recording appointment data that was written in an email,
> so it's important to be able to provide dates and times in addition to
> just strings.  Ideally start *and* end times, either as dates or as Lisp
> timestamps, without having to worry about formatting them.  It would
> also be useful to be able to provide values for properties that Org
> recognizes, like LOCATION or ID.

What is interesting, some email support is already available in
`org-link-store-props' (read - for all links types). Via
`mail-extract-address-components':

| Link type    | Available keywords                                       |
|--------------+----------------------------------------------------------|
...
| mh, rmail    | =%:type=, =%:subject=, =%:message-id=                    |
|              | =%:from=, =%:fromname=, =%:fromaddress=                  |
|              | =%:to=, =%:toname=, =%:toaddress=                        |
|              | =%:date= (message date header field)                     |
|              | =%:date-timestamp= (date as active timestamp)            |
|              | =%:date-timestamp-inactive= (date as inactive timestamp) |
|              | =%:fromto= (either "to NAME" or "from NAME")[fn:32]      |
...

> Maybe it makes sense to have *two* plists (or a plist and an alist): one
> to provide values for the existing %-escapes, and one mapping arbitrary
> property names to string values which can be stored in a properties
> drawer.
>
> WDYT?

Could you explain more why you need something separate for properties
drawer? Maybe with an example.

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to