Search code examples
emacsyasnippet

yasnippet insert the current date


I tried to create a template which insert a transaction with the current date

# -*- mode: snippet -*-
# name: breakfast
# key: breakfast
# condition: t                    
# --

2019-09-05 * ""
           Assets:DebtWechat  CNY
           Expenses:Food:Breakfast

How could change 2019-09-05 to a insert-current-date function?


Solution

  • You can embed elisp code in your snippet. For your example, you could use something like

    `(format-time-string "%Y-%m-%d")` * ""