Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keeping the context when archiving in Emacs org-mode

Tags:

emacs

org-mode

I generally use org-mode to keep track of TODOs. I have files like:

* Misc.
** TODO Task 1
** TODO Task 2
* Project 1
** TODO Task 1
** TODO Task 2

While archiving whole subtrees like Project 1 work as intended, I am not to able to move Task 1 in Misc. such that the archive file looks like this (ignoring PROPERTIES in this example):

* Misc
** DONE Task 1

In other words, I want to keep all sections a task belongs to. Is there a quick way to do this?

like image 990
Renke Grunwald Avatar asked Apr 13 '12 15:04

Renke Grunwald


1 Answers

You likely want to set the :ARCHIVE: property on the parent headlines.

It allows you for headline specific org-archive-location settings. (See the manual)

For example if your archive file is set as %s_archive you would want your original file to look like this

* Misc.
  :PROPERTIES:
  :ARCHIVE:  %s_archive::* Misc
  :END:
** TODO Task 1
** TODO Task 2
* Project 1
  :PROPERTIES:
  :ARCHIVE:  %s_archive::* Project 1
  :END:
** TODO Task 1
** TODO Task 2

This would sent any subtrees in * Misc to a * Misc headline in the archive file, and would do the equivalent for the subtrees in Project 1 (unless you archive the whole tree in one shot). Archiving the parent tree after the subtrees appears to add it as an additional subheading under the destination. It does not support multiple levels, so you'd have to set up your archive file headlines ahead of time to ensure it outputs the way you desire if you need a complex setup of that sort.

You can also use this property to archive specific trees to separate files (for export/publication/sharing purposes).

like image 131
Jonathan Leech-Pepin Avatar answered Sep 22 '22 07:09

Jonathan Leech-Pepin