Ihor Radchenko <[email protected]> writes:

>>>> That's more or less the approach I've settled on.
>>>> I'm binding org-capture-initial and org-overriding-default-time so
>>>> a simple template like "* %i %T" works.
>>>>
>>>> Neither of these variables is documented, though -- I'm not sure if
>>>> that's just an oversight, or if it means "Please don't use this as a
>>>> public API".
>>>
>>> Yes that looks more risky than defining our own vars, in any case, it 
>>> would be nice to document/agree on how to extend org-capture 
>>
>> Carsten, Ihor, could you perhaps comment on this?  Is it safe to bind
>> these variables from external code, or should I avoid it?  Would you be
>> interested in a patch to add docstrings to them?
>
> I plan to add docstring for org-overriding-default-time:
>
> (defvar org-overriding-default-time nil
>   "When non-nil, default time to be used by `org-read-date'.
> This time is used regardless of the other time arguments and other
> contexts.  The value must be a time object, as in `current-time'.")
>
> org-capture-initial and org-capture-link-is-already stored will likely
> stay internal.

Good to know! Thanks for following up on this.

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

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.

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?

Best,
Richard


Reply via email to