Setting up a journaling system with Emacs
I’m a big proponent of the need for a “brain dump” somewhere. Hundreds of good conversations had, cool links I randomly stumble across, detailed happenings in my professional life and so on. In the past, I’ve used different technologies for each of these simply because I had different tools in different places. Non-network desktops at school, notepads for homework, a laptop at work and perhaps a small diary at home if I wanted. The last one there, I’ll admit I could not even be bothered to use consistently. But I’m convinced that there’s a better way to do it now that many parts of my life take place with me having access to the same tools and technologies. This is truly something to celebrate in all the doom and gloom that forms 2020. I’m able to see my emails, work, communicate with my family and record personal tasks completely independentently of my location. But, to be frank, all this access hasn’t led me to keeping a streamlined process because humans will do human things. So much entropy around me! My emails are all over the place, I have cool links saved in chats with friends, simply because I’m too lazy to extract them somewhere. Will it even help if they were in a bookmarks folder instead? I mean all that still means that I have to think backwards… “Hey, where did I come across this term before? Oh right! In a conversation with Andrew. I guess I need to go to my chat with Andrew to search for the link… but was it on Signal or Whatsapp?” And so it goes! No, I think a simpler solution is in order, and in this case, I’m using a robust tool I’m already in love with: Emacs. So let’s set up the problem and propose a solution then!
Requirements for a journaling system
I have a small number of very crucial requirements:
It needs to be digital
I admit there is charm in writing something in a battered old notebook. And if that works for you, by all means please use that – this is by no means prescriptive. But in my case, practicality wins and I want to have this journal in a digital format to enable me to analyze trends, rapidly search content and not worry about archiving or loss of material. Think: ripping through it with regexes and maybe even some NLP. I think of it as a database of sorts – I need to design it such that whatever query I think of, I can probably do it without to much hassle. Even if this wasn’t the case, I can scarcely read my own handwriting at times. I don’t trust my fickle self!
I need to remove all the friction of entering records
It needs to be as easy as cracking open a physical diary and scribbling something down very quickly. The more friction there is to data entry, the less likely I am to use it. I have emacs more or less always open, whether at work or home and for this purpose, I can use a capture template to quickly open a pre-filled form. So in a few keystrokes, I have a blinking cursor waiting for me to input something.
I need to own the data
I can’t stress this one enough. I’m not investing years of my life feeding in details about myself into some preform walled garden operated by a company that neither respects my ownership and privacy rights and can just as easily cease to operate and leave me high and dry without my data. All this my entries should be available in plain text so I can run with them wherever I want, build apps that can parse them and archive them without ever worrying about a specific program being needed. Even if my beloved Emacs were to one day cease to exist, I need all the stuff I’ve typed out in a format I can move with. Because nothing lasts forever.
I need not worry about time or pages or other fluff
I am a mere mortal and cannot appreciate the passage of time well enough. While recording my entries, I don’t need to be thinking about what the day is, where I’ve reached in this whole story… I just need to put stuff down. The analysis part is completely separate from the data entry part so let’s keep it that way. No fluff here plox.
Setting up a journal using Emacs’ org-capture
Enable org-capture
Org-capture is an amazing subwormhole within the emacs orgmode wormhole. I won’t go into depth here, but feel free to check it out here. In a nutshell, capture lets you quickly store snippets within preset templates. So within a few keystrokes, you can archive something in your clipboard or start a new blog post for example.
So let’s enable capture first. In this case, we’ll bind it to the default Ctrl-C C binding (C-c c). You can enable other features like agenda mode; see the capture manual above. Add this line to your .emacs.d or init.el file. Doesn’t matter which one, and you can actually have multiple dotfiles for config, but you probably want to have some deliberate choices made to avoid tedious troubleshooting.
(global-set-key (kbd "C-c c") 'org-capture)
Save your file and restart emacs or execute it and evaluate the buffer. You can now test out whether capture mode works with C-c c. A buffer should pop up that asks you whether you want to create a new capture template. Ignore all this for now. You can kill that buffer or cancel the operation.
Set up a journal template file
We’ll now save a default journal file where all our saved notes will go to. This will have a “datetree” structure which you can think of like a diary: an org file with a nested series of headers that consist of the date and your notes – in org mode again – stored as the content.
Add this to your init file below your binding for org-capture:
(setq org-capture-templates
'(
("j" "Journal entry" plain
(file+datetree"~/Documents/personal/journal.org")
"%?")
))
Save the file and restart emacs or evaluate the buffer, and you’re good to go!
Using the journal
- Fire up emacs
- Trigger org-capture with C-c c
- You should see an option for “journal entry” with key code “j”
- Select the date you want to make an entry for using S-left or S-right. Note relative dates can also be entered e.g. -3d for something 3 days ago.
- Enter your journal entry using org-mode
- Once finished, press C-c C-c to file it
- Your entry is now saved in a journal.org file created in the directory we specified above.
A preview of the journal output
Next steps
I strongly believe the act of recording information should be completely detached from any form of analysis. These steps let you create a template to capture snippets of everyday life quickly. There’s an infinite number of things you can do from this point onwards. Some options might be to export as a book using org-export, grep for items whenver you want to recall details, analyze the date + keywords using a scripting language to track your habits. Do your thing!