[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Capture Template Diary Entry: file+datetree+prompt use the prompted time
From: |
Nils Schween |
Subject: |
Capture Template Diary Entry: file+datetree+prompt use the prompted timestamp including the time when time is specified |
Date: |
Mon, 18 May 2020 12:59:47 +0200 |
Dear members of the org-mode mailing list,
a week ago I spent some time to set up a capture template to
directly write appointments to my calendar file (i.e. to write
diary entries). It looks as follows:
("d" "Diary entry" entry (file+datetree+prompt
"~/MPIK-Nextcloud/emacs/.org/kalender.org")
"* %i%?\n %T")
And it works as expected: When calling the capture template, I am prompted for a
date and I can also type a time, and on saving everything is stored at the
correct location in the datetree. Perfect. But in case I do not enter a time,
00:00 is inserted. This is unfortunate. Okay, I can replace "%T" in the template
with "%t", but then any specification of time is ignored.
Instead, I would love to mimic the behaviour of the function "org-time-stamp".
Calling it
prompts for a date, and if I do not specify a time, only the date is inserted.
In case I specify a time or a range (i.e. 10:00-12:00) the timestamp is
supplemented with this additional information.
The use-case is the following: Some of my appointments last a whole day, and
others start at a specified time and some of them last e.g. only two hours. To
capture all these cases, I would need a template expansion inserting the
timestamp as I entered it when prompted, i.e. if a specify a time, it includes
it and if not it does not. Of course, this should also be true for e.g.
(10:00-12:00).
I tried a lot to get the desired behaviour by testing variants of the following
combination of org-mode functions and variables.
%(org-insert-time-stamp (org-read-date nil t org-read-date-final-answer) t)
I was not able to produce what I wanted.
Does anyone have a workaround or an idea how I could implement the described and
wished behaviour? Thanks.
With best regards,
Nils
- Capture Template Diary Entry: file+datetree+prompt use the prompted timestamp including the time when time is specified,
Nils Schween <=