From: Ihor Radchenko <yantar92@gmail.com>
To: Skip Collins <skip.collins@gmail.com>
Cc: emacs-org list <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Re: [BUG] folding error during capture
Date: Mon, 02 May 2022 10:05:57 +0800 [thread overview]
Message-ID: <87ilqovgca.fsf@localhost> (raw)
In-Reply-To: <CABUh-76ZDr+BcEv6Ozx6fSsXeEtp=n3FrUMMjq4aV66NyvX__Q@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1016 bytes --]
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.
[-- Attachment #2: 2022-05-02_09-56.png --]
[-- Type: image/png, Size: 6165 bytes --]
[-- Attachment #3: Type: text/plain, Size: 807 bytes --]
> 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
next prev parent reply other threads:[~2022-05-02 2:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-01 20:51 [BUG] folding error during capture Skip Collins
2022-05-02 0:17 ` [PATCH] " Ihor Radchenko
2022-05-02 1:36 ` Skip Collins
2022-05-02 2:05 ` Ihor Radchenko [this message]
2022-06-09 8:16 ` Ihor Radchenko
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
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ilqovgca.fsf@localhost \
--to=yantar92@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=skip.collins@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 public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).