How to archive all the DONE tasks using a single command

前端 未结 5 814
栀梦
栀梦 2020-12-07 08:49

To archive the DONE tasks i am using

C-c C-x a

command. The draw back is i have to manually move over the DONE tasks one by one and then ar

相关标签:
5条回答
  • 2020-12-07 09:35

    Here's a corrected version of madalu's snippet. Note that this version also only operates on the current subtree (change 'tree back to 'file to operate over the entire file).

    (defun org-archive-done-tasks ()
      (interactive)
      (org-map-entries
       (lambda ()
         (org-archive-subtree)
         (setq org-map-continue-from (org-element-property :begin (org-element-at-point))))
       "/DONE" 'tree))
    
    0 讨论(0)
  • 2020-12-07 09:44

    Also from http://orgmode.org/manual/Moving-subtrees.html#Moving-subtrees

    C-u C-c C-x C-s

    Check if any direct children of the current headline could be moved to the archive. To do this, each subtree is checked for open TODO entries. If none are found, the command offers to move it to the archive location. If the cursor is not on a headline when this command is invoked, the level 1 trees will be checked.

    0 讨论(0)
  • 2020-12-07 09:49

    You can write a function using org-map-entries:

    (defun my-org-archive-done-tasks ()
      (interactive)
      (org-map-entries 'org-archive-subtree "/DONE" 'file))
    
    0 讨论(0)
  • 2020-12-07 09:49

    You can bulk archive (or refile/change todo etc) from within the Agenda view.

    http://orgmode.org/manual/Agenda-commands.html#Agenda-commands

    If you call Org-Agenda from within the buffer you want to archive you can temporarily restrict it to only that buffer and view only todo entries and filter for only DONE

    C-c a < t
    N r
    

    Where N corresponds to the shortcut for your DONE state (with default states it would be 2)

    Then you'd simply need to mark all the desired headlines and bulk archive

    m (mark for bulk action)
    B a (or B $ for arch->sibling)
    
    0 讨论(0)
  • 2020-12-07 09:49

    If you want to do it in the source Org buffer (as opposed to in an Org agenda view), and if they are following each other, you can select all of them in a region, and apply a command (such as C-c C-t d).

    Only setting needed:

    ;; Some commands act upon headlines in the active region.
    (setq org-loop-over-headlines-in-active-region 'start-level)
    
    0 讨论(0)
提交回复
热议问题