如何使用单个命令归档所有已完成的任务

发布于 2024-11-28 19:37:50 字数 126 浏览 0 评论 0原文

为了存档已完成的任务,我正在使用

C-c C-x a

命令。缺点是我必须手动将已完成的任务一一移动,然后将其存档。

如何使用单个命令归档所有已完成的任务。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

忆依然 2024-12-05 19:37:50

您可以从议程视图中批量存档(或重新归档/更改待办事项等)。

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

如果您从要存档的缓冲区内调用 Org-Agenda,您可以暂时将其限制为仅该缓冲区,并仅查看待办事项条目并过滤仅完成的内容,

C-c a < t
N r

其中 N 对应于完成状态的快捷方式(默认状态为 2)

然后您只需标记所有所需的标题和批量存档

m (mark for bulk action)
B a (or B $ for arch->sibling)

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)
差↓一点笑了 2024-12-05 19:37:50

这是 madalu 片段的更正版本。请注意,此版本也仅对当前子树进行操作(将“tree”更改回“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))

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))
你对谁都笑 2024-12-05 19:37:50

您可以使用 org-map-entries 编写一个函数:

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

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

(defun my-org-archive-done-tasks ()
  (interactive)
  (org-map-entries 'org-archive-subtree "/DONE" 'file))
柒夜笙歌凉 2024-12-05 19:37:50

也来自 http://orgmode.org/manual/Moving-subtrees.html#Moving -子树

Cu Cc Cx Cs

检查当前标题的任何直接子项是否可以移动到存档中。为此,将检查每个子树是否有打开的 TODO 条目。如果没有找到,该命令会建议将其移动到存档位置。如果调用此命令时光标不在标题上,则将检查 1 级树。

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.

呆萌少年 2024-12-05 19:37:50

现在有一个命令 org-archive-all-done 内置于 org-mode 和 org-archive.el 中。

There is now a command org-archive-all-done that is built into org-mode, and in org-archive.el.

ゞ花落谁相伴 2024-12-05 19:37:50

基于罗伯特的回答

(require 'org)
(require 'org-archive)
(add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook 'org-archive-all-done nil t)))

Based on Robert's Answer

(require 'org)
(require 'org-archive)
(add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook 'org-archive-all-done nil t)))
何必那么矫情 2024-12-05 19:37:50

如果您想在源组织缓冲区中执行此操作(而不是在组织议程视图中),并且如果它们彼此关注,则您可以选择一个区域中的所有它们,然后应用命令(例如抄送 Ct d )。

只需要设置:

;; Some commands act upon headlines in the active region.
(setq org-loop-over-headlines-in-active-region 'start-level)

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)
美男兮 2024-12-05 19:37:50

我发现其中几个答案中的直接“org-map-entries”方法由于某种原因在多个级别的嵌套和 TODO 更加多样化的情况下有点“脆弱”。

这种方法 - 生成一个列表,然后反向归档(以避免定位变化)似乎涵盖了我抛出的每个用例。在这里分享给其他遇到麻烦的人。

请注意,最后一行的“TODO”字符串匹配需要与您精确定义 TODO 的方式相匹配(例如,在普通情况下,匹配可能是:"TODO=\"DONE\"" )。

(defun org-archive-done-tasks ()
  "Archive all tasks marked DONE in the file."
  (interactive)
  (mapc (lambda(entry)
          (goto-char entry)
          (org-archive-subtree))
        (reverse (org-map-entries (lambda () (point)) "TODO=\"★ DONE\"" 'file))))

I found the direct "org-map-entries" method in a couple of these answers to be a little "fragile" for some reason in situations with more varied nesting and TODOs at multiple levels.

This method - generating a list and then archiving in reverse (to avoid changes in positioning) seems to cover every use case I've thrown at it. Sharing it here for anyone else that runs into trouble.

Note the "TODO" string match on the last line needs to match how you have your TODOs defined exactly (for example in a vanilla case, the match may be: "TODO=\"DONE\"").

(defun org-archive-done-tasks ()
  "Archive all tasks marked DONE in the file."
  (interactive)
  (mapc (lambda(entry)
          (goto-char entry)
          (org-archive-subtree))
        (reverse (org-map-entries (lambda () (point)) "TODO=\"★ DONE\"" 'file))))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文