0

I use org-archive-subtree to clean my org files. Most of my tasks lie under * Tasks header so I run the function on it using prefix (C-u C-c C-x C-s). I noticed that the function only asks for confirmation when it encounters a DONE task.

Would it be possible to change its behavior to:

1) Ask only when the item has DONE state and it has a CLOSED timestamp that's at least month old (or does not have this timestamp at all but is still in DONE). I like to review my last week seeing what I did so archiving too young tasks breaks this option for me.

2) Do the above checks but archive without asking if the conditions are met.

  • Until the desired function is found/written, a hack solution is to make a custom agenda view that shows tasks that meet this requirement, and then bulk archive from the agenda view. – mankoff Feb 22 '18 at 6:27
  • There's an example of exactly that agenda-based approach here: doc.norang.ca/org-mode.html#Archiving I've been using that for a while in my own init and it's been working well. – Stuart Hickinbottom Feb 24 '18 at 16:57
  • @StuartHickinbottom yes this seems to be exactly it. Unfortunately I cannot figure out how can I use this skipping function when calling the archive function. – kajman Mar 3 '18 at 10:46
  • @kajman You can set up a custom agenda command to display that agenda, then use bulk agenda commands to mark them for archiving. e.g. the following then "C-c a A", then "m" to mark tasks you want to archive, then "B $" to archive the marked tasks. Not as long-winded as it sounds when you try it! (setq org-agenda-custom-commands (cons '("A" "Candidate trees for archiving" tags "-NOARCHIVE" ((org-agenda-overriding-header "Candidate tasks for archiving") (org-agenda-skip-function 'my-skip-non-archivable-tasks))) org-agenda-custom-commands)) – Stuart Hickinbottom Mar 3 '18 at 17:59
  • @StuartHickinbottom Thanks this works great. Can you shed some light how did you come up with the solution? I feel almost retarded when I try configure my emacs, it always all seems like guessing to me and it takes forever to come with a solution like this. Do you have any hints, what to read, where too look etc? I tried looking into docus, read about the variables I thought could be changed and so on. Even having this function didn't help to configure this on my own. This seems simple but I cannot do it on my own so it irritates me a lot! – kajman Mar 5 '18 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.