I spent some time reading through the manual for part 3 of organizing my life in org-mode. org-mode has an archiving function I haven’t bothered with in the past because dumping old files into a folder was easier to do.

There was this interesting example under org-archive-subtree help text:

“~/org/datetree.org::datetree/* Finished Tasks” The “datetree/” string is special, signifying to archive items to the datetree. Items are placed in either the CLOSED date of the item, or the current date if there is no CLOSED date. The heading will be a subentry to the current date. There doesn’t need to be a heading, but there always needs to be a slash after datetree. For example, to store archived items directly in the datetree, use “~/org/datetree.org::datetree/”.

Ah ha! So you refile a task and put it away in a different file (this is what archiving does by default in Emacs) and store it in its appropriate month. Not only that, the function will look for when you finished working on a project and automatically store it on that date in a header of your choosing. Good stuff.

For example, let’s say I started to write a technical document at work about pink rabbits (I’m in a good mood, OK? Bare with me, I’ll get grumpy soon enough) and this project includes a couple of subheaders: a meeting we had about the project, a task to backup the existing version of the document, and a couple of more TODOs regarding images and sending it for approval by subject matter experts. So far so good, this starts in Now.org where I keep working on the project and add to my notes.

Let’s continue with the example. Two months later, I’m done with the pink rabbits projects. I go to the parent header in my Now.org file, “update Pink Rabbits document,” and change its keyword from ACTIVE (my keyword for projects) to DONE. Since I have the keyword “ACTIVE” defined with ! in the file’s options (this is defined by the line #+TODO: TODO(t) ACTIVE(a!) MEETING(m!) | DONE(d!) CANCELED(c) at the top of the file - you can see ACTIVE is triggered by a! while its neighbor, TODO, is only t which means a timestamp will not be added), org-mode adds a timestamp for when I marked it DONE.

There are three basic scopes of defining where to put the archived headers. I can define one file in my init file for org-archive-subtree, which will create a global definition and thus a file for everything (not very useful), or I can define the destination for the archive at the top of the org file (so Now.org will have a line: #+ARCHIVE: my/path/is/here), or, I can go into the individual headers and define it there as a property with Archive: my/path/here. This last one is best for me, as I can quickly define headers for, say, article updates, announcements, and misc, each one of these parent headers pointing to a different file, if I want to do that. Nice indeed.

With the datetree option above, these archived tasks will be filed in these files and under the date and time I finished the project. The archive function will include properties in each telling me exactly where these projects came from.

I was about to start using this, but there’s only one problem… I haven’t found out how to restore something back from the archive.

Back to the example. Say I thought we were done with our pink rabbits document so I archived it away. Then, next month, someone says “Hey, JTR, we need to mention the catapults we’re implementing with the pink rabbits. Can you add it?” I say “Sure, no problem!” After all, I have the power of Emacs and it takes me less than a minute to find this project in my archive (consult-grep is amazing for this sort of thing).

So go to the archive file, I find it, and… I want to pull it out of the archive and put it back into my Now.org as one of my active projects… but… how do I do that?

I can be barbaric and go around killing and yanking, but there must be a better way, right? I think? Grrrr… (see, back to my grumpy self).