How to archive all the DONE tasks using a single command

陌路散爱 提交于 2019-11-27 05:00:34

问题


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 archive it.

How to archive all the DONE tasks using a single command.


回答1:


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

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



回答2:


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)



回答3:


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))



回答4:


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.




回答5:


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)


来源:https://stackoverflow.com/questions/6997387/how-to-archive-all-the-done-tasks-using-a-single-command

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!