Duplicate tree structure in org-mode archive

Is Orgmode under Emacs programmed to automatically duplicate a tree structure in the archive above the element being archived?

My new org-mode structure in the file looks like this:

* CONFIGURE
** Operating Systems
*** Debian Unstable
*** Demodyne

** Machines
(...)
** Software
(...)

      

After archiving the "Demodyne" entry, I would like the archive to contain the following:

* CONFIGURE
** Operating Systems
*** Demodyne

      

I thought I saw this in the org-mode documentation when I started using it many, many years ago, but I didn't find anything like it in the latest version's documentation at http://orgmode.org/manual/ ( http: / /orgmode.org/manual/Archiving.html#Archiving is pretty short). I feel like I can program this, but I would rather not if I had done it before ...

+5


source to share


1 answer


Partial solution for this at https://gist.github.com/edgimar/072d99d8650abe81a9fe7c8687c0c993 .

This might be a really good solution, however, it only works for me on one task DONE

. If I try to propagate it to all tasks DONE

in a subtree using org-map-entries

as below, it creates a new * ARCHIVED

top-level header * ARCHIVED

every time it runs. Is there a way to avoid this unwanted behavior?

Example of unwanted behavior with org-map-entries

Define a function to work on all DONE

tasks in the current subtree:

(defun org-archive-done-tasks ()
  (interactive)
  (org-map-entries 'org-archive-subtree-hierarchical "/DONE" 'tree))

      

Note: org-archive-subtree-hierarchical

found in the link above.

Now if I take the next buffer



* Project 1
** TODO Task 1
** TODO Task 2
** TODO Task 3

      

and check Task 1 DONE

, run org-archive-done-tasks

for Project 1 and then do the same for Task 2, the buffer will give

* ARCHIVED
** Project 1
*** DONE Task 1

* ARCHIVED
** Project 1
*** DONE Task 2

* Project 1
** TODO Task 3

      

Here is the desired output that would occur if org-archive-subtree-hierarchical

run directly on ** DONE Task 1

and then ** DONE Task 2

(as children * Project 1

)

* ARCHIVED
** Project 1
*** DONE Task 1
*** DONE Task 2

* Project 1
** TODO Task 3

      

Is the desired behavior possible using org-map-entries

? Is there a better way to do this org-archive-subtree-hierarchical

for all tasks DONE

in a subtree multiple times without duplicating the archive header?

0


source







All Articles