1

I created a yasnippet template to quickly timestamp a note I'd like to make in org-mode. The body of the yasnippet file reads

$0 
:PROPERTIES:
:CREATED: `(org-insert-time-stamp nil t t)`
:END:

However, the effect is the CREATED property being populated with double inactive timestamps, e.g., :CREATED: [2015-06-16 Tue 10:08][2015-06-16 Tue 10:08]. Why is this behavior occurring, and how do I prevent the redundant timestamp?


References:

Note: Trying either one of the methods described in the reference links yields the same doubled timestamp result.

4

This happens because org-insert-time-stamp inserts a time stamp (like the name says), but also returns the time stamp. Yasnippit inserts the return value but you're also left with the one inserted by the function call. A fix is to capture the return value, leaving only the inserted value: (let ((x (org-insert-time-stamp nil t t )))).

  • Great! Thanks for that explanation, @erikstokes. – kgo Jun 17 '15 at 12:43
0

Adapted from an answer found in Elisp - Avoid prompt in interactive function, the following body of the yasnippet file works, but I'm sure there's a better solution using (org-insert-time-stamp) or similar. This also doesn't address the peculiar double timestamp behavior described in the original question.

$0
:PROPERTIES:
:CREATED: `(insert (format-time-string "[%Y-%m-%d %a %H:%M]"))`
:END:

NOTE: This solution does oddly leave two spaces between :CREATED: and the inserted timestamp. I'm not sure why.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.