emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [PATCH] Re: [BUG] folding error during capture


From: Ihor Radchenko
Subject: Re: [PATCH] Re: [BUG] folding error during capture
Date: Mon, 02 May 2022 10:05:57 +0800

Skip Collins <skip.collins@gmail.com> writes:

>> > ("n" "Note" entry
>> >       (file "~/Documents/org/beorg/capture.org")
>> >       "* %^{note} :note: %(org-set-property \"Created\"
>> > (org-time-stamp-inactive '(16)))" :immediate-finish t)
>> ...
>> This is quite a hacky capture template...
>
> I'll take that as a compliment.

It was not. Your template expansion only works by accident because of
internal details of implementation of org-capture-fill-template.

In particular, org-time-stamp-inactive not only returns a timestamp, but
also _inserts_ it at point (see the screenshot of interim buffer state
while expanding your template). The fact that this inserted timestamp
gets deleted is simply because (1) org-capture-fill template does not
expect the buffer to be changed by other functions; (2) org-capture-fill
internally marks %(sexp) with sticky text property and deletes
everything marked with that property at the end of expansion; (3)
org-time-stamp-inactive respects text property stickiness.

PNG image

> The general ability to set properties during capture seems very
> reasonable. It might be best to have a specific interface as an
> alternative to my hack. The use of %(EXP) in capture templates is
> intended to insert a string returned by the elisp EXP. I bent the
> rules slightly to set the Created property. There already exists a way
> to set property values in capture templates via %^{PROP|default}p, but
> that results in a user prompt. Perhaps a new template construct like
> %^{PROP|value}v could be introduced in order to set a property value
> without a prompt. Then I could use %^{Created|%u}v in the template.

What about the template below?

("n" "Note" entry
(file "~/Documents/org/beorg/capture.org")
"* %^{note} :note:
:PROPERTIES:
:CREATED: %u
:END:
"
:immediate-finish t)

Best,
Ihor

reply via email to

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