Archiving in emacs org-mode

23 Mar 2018
7
minute read

Emacs org-mode’s focus on plaintext organizing files is surprisingly powerful.
However, archiving files to keep thing lean and fast becomes important as your
corpus grows. To fit with my GTD style, I took an alternative approach to
org-mode’s native archiving and automated it.

My GTD style heavily revolves around a daily org-journal file that collects
notes and TODO items into a rational structure for reference and tasks tagged
by various semantic grpups, critical to moving forward my 100+ person
team. Separate from project files, habits, or my repeating tasks org-journal
daily files end up being the meat of moving forward and tracking things across
the large organization.

The issue is that long individual fies obviously add up quickly as I have one
each day and having agenda or various search modes parse all those files and
log and property drawers can slow things down.

While org-mode has an interesting subtree archiving feature, technically that is
more useful for project files, rather than the dailies that end up running my
day to day.

To keep things fast and remove the no longer relevant, I waned to have those
files archived whenever all the various TODO states had moved to DONE or
KILL (my cancelling them.).

So, I wanted a series of lisp functions to:

Parse all files in my journal file directory

For each file, determine if there were any active TODOs.

If all TODOs are in a Done state, rename the file to .org_archive

Otherwise, move onto the next file

Sounds simple, right? But while I was confident I could knock this off in bash
or another scropting language pretty handily, I wanted to do this in elisp in
order to get a little better at bending emacs to my will.

This is what I came up with, which works beautifully, but involved me reading
and lifting code from actual org-mode as well as spending a little more time
getting into elisp than I would have otherwise hoped (see note in emacs org-mode
GTD post about whether I spend more time bending emacs to my will and fiddling
with it than the productivity benefits it delivers.)

You can place this code funciton in your ~/.emacs.d/init.el to have it
autload. Then just trigger M-x archive-done-org-journal-files after making
sure to change the file path to reflect where your dailies files are kept. Just
by way of explanation, I keep everything under a directory for Deft for quick
searching and then have org-journal create files in a directory under that.

That’s it! Works the charm for me and so far has kept things very fast.

Two things you probably want to do if you do ocassionally have to go back
in time and search for things is add the modifications into your init.el as
well.