Create Journal Note For a Previous Day in denote.el
Some days I forget to run Denote to create a new journal file for the day, and then the appropriately named note file is missing when I want to write down things later. That’s not how you use a daily journal, I know, but I use Emacs and denote.el
to write down things like exercise logs or when I get sick, and these are information I can backfill easily the day after.
A solution that works for me is to (setq denote-prompts '(date))
– then I can run M-x denote-create-note
and enter the date to backfill. It won’t insert the appropriately formatted title or tags of my journal notes, but that’s not a big deal.
Learn How to Find This in a Foreign Code Base
My denote-id-format
is "%Y%m%d%H%M"
(a date-time string that produces 2024-06-27 07:14
but without any separators and punctuation), so I started looking from there:
- From the C-h v variable overview, select the
denote-id-format
variable. - In the help buffer, follow the link to
denote.el
’s source code at the top. This takes you to where the variable is defined. - Run M-x
occur
on the variable name to find where it’s being used. - One of the few occurrences is
denote-prompt-for-date-return-id
, which sounds exactly like what I want! But it’s not interactive, so: - Run M-x
occur
ondenote-prompt-for-date-return-id
to find where this is being used. - That took me to the middle of
denote-dired-rename-files
, a rather long function, and I found that the prompt is being run based on thedenote-prompts
variable.
Setting denote-prompts
to '(date)
and running denote-create-note
afterwards confirmed that this did the trick.
I admit I didn’t actually run M-x occur
manually, but resorted to embark-act
on the symbol-at-point for everything. I used Embark to run occur
, to change denote-prompts
from the variables list, even to insert the denote-id-format
value above.