有没有办法让子任务在组织模式下继承截止日期?

发布于 2024-10-15 18:42:30 字数 111 浏览 2 评论 0原文

如果对于 org 模式下的某些任务,子任务可以继承主任务的截止日期,那就非常方便了。如果我尚未指定子任务的截止日期,则会出现此行为。这样,所有子任务都会显示在我的组织议程视图中,并具有易于操作的适当截止日期。

It would be really convenient if for certain tasks in org-mode, the subtasks could inherit the deadline of the main task. This behavior should occur in case I have not already specified a deadline for the subtask. In this way, all the subtasks would show up in my org-agenda view, with proper deadlines which are easily manipulatable.

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

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

发布评论

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

评论(6

甜心小果奶 2024-10-22 18:42:31

添加子任务的功能怎么样?如果子任务的父任务有一个截止日期,则此一项会为子任务添加截止日期:

(defun my-org-insert-sub-task ()
  (interactive)
  (let ((parent-deadline (org-get-deadline-time nil)))
    (org-goto-sibling)
    (org-insert-todo-subheading t)
    (when parent-deadline
      (org-deadline nil parent-deadline))))

不要忘记将其绑定到一个键:

(define-key org-mode-map (kbd "C-c s") 'my-org-insert-sub-task)

此外,您可能会发现这些设置很有用:

(setq org-enforce-todo-dependencies t)
(setq org-agenda-dim-blocked-tasks 'invisible)

How about a function for adding subtasks? This one adds a deadline to the subtask if its parent has one:

(defun my-org-insert-sub-task ()
  (interactive)
  (let ((parent-deadline (org-get-deadline-time nil)))
    (org-goto-sibling)
    (org-insert-todo-subheading t)
    (when parent-deadline
      (org-deadline nil parent-deadline))))

Don't forget to bind it to a key:

(define-key org-mode-map (kbd "C-c s") 'my-org-insert-sub-task)

Also you might find these settings useful:

(setq org-enforce-todo-dependencies t)
(setq org-agenda-dim-blocked-tasks 'invisible)
甜柠檬 2024-10-22 18:42:31

这是适用于最新版本的 Org 9 的建议,与我之前的答案不同,它在某个时候停止工作。

(defun org-entry-properties-inherit-deadline (orig-fun &optional pom which)
  "Call ORIG-FUN with POM, but if WHICH is `DEADLINE' do it recursively."

  (if (string= which "DEADLINE")
      (org-with-point-at pom
        (let (value)
          (while (not (or (setq value (funcall orig-fun (point) which))
                          (not (org-up-heading-safe)))))
          value)
    (funcall orig-fun pom which))))
(advice-add 'org-entry-properties :around #'org-entry-properties-inherit-deadline)

Here's advice that works for recent versions of Org 9, unlike my previous answer which stopped working at some point.

(defun org-entry-properties-inherit-deadline (orig-fun &optional pom which)
  "Call ORIG-FUN with POM, but if WHICH is `DEADLINE' do it recursively."

  (if (string= which "DEADLINE")
      (org-with-point-at pom
        (let (value)
          (while (not (or (setq value (funcall orig-fun (point) which))
                          (not (org-up-heading-safe)))))
          value)
    (funcall orig-fun pom which))))
(advice-add 'org-entry-properties :around #'org-entry-properties-inherit-deadline)
罗罗贝儿 2024-10-22 18:42:31

最近,这个问题在 org-mode 邮件列表上被提出和回答。我在这里添加该讨论是希望有人会发现它有用:

http:// Article.gmane.org/gmane.emacs.orgmode/49215

我已将该代码添加到此提交中的 .emacs 中:

https://github.com/vedang/emacs-config/commit/1cb6c774a991d50853134d8085ca61dd12585993

Recently, this question was asked and answered on the org-mode mailing list. I'm adding that discussion here in the hopes that someone will find it useful:

http://article.gmane.org/gmane.emacs.orgmode/49215

I've added that code into my .emacs in this commit:

https://github.com/vedang/emacs-config/commit/1cb6c774a991d50853134d8085ca61dd12585993

任性一次 2024-10-22 18:42:31

DEADLINE 是这些属性之一,默认情况下不会继承。
您可以通过自定义变量 org-use-property-inheritance 来更改它

DEADLINE is one of these properties, that are not inherited by default.
You can change that by customizing the variable org-use-property-inheritance

两相知 2024-10-22 18:42:31

Org-mode 能够继承诸如截止日期之类的标签,但默认情况下 org-entry-get 不会这样做。以下是确保 DEADLINE 始终被继承的建议。

(defvar inherit-override nil)
(defun org-entry-get-inherit-deadline (orig-fun pom property &optional inherit &rest args)
  "Call ORIG-FUN with POM, but if PROPERTY is `DEADLINE', set INHERIT.

Passes through remaining ARGS.

Sets inherit-override variable which stops infinite loops."
  (when (and (eq inherit nil)
             (string= property "DEADLINE")
             (not inherit-override))
    (setq inherit t))
  (let ((inherit-override t))
    (apply orig-fun pom property inherit args)))

(advice-add 'org-entry-get :around #'org-entry-get-inherit-deadline)

Org-mode has the capability to inherit tags like deadlines, but by default org-entry-get does not do so. Here's advice to ensure that DEADLINE is always inherited.

(defvar inherit-override nil)
(defun org-entry-get-inherit-deadline (orig-fun pom property &optional inherit &rest args)
  "Call ORIG-FUN with POM, but if PROPERTY is `DEADLINE', set INHERIT.

Passes through remaining ARGS.

Sets inherit-override variable which stops infinite loops."
  (when (and (eq inherit nil)
             (string= property "DEADLINE")
             (not inherit-override))
    (setq inherit t))
  (let ((inherit-override t))
    (apply orig-fun pom property inherit args)))

(advice-add 'org-entry-get :around #'org-entry-get-inherit-deadline)
丢了幸福的猪 2024-10-22 18:42:31

另一种方法是在 org-agenda-mode 中使用 org-agenda-bulk-action 。

  1. stuck-projects 定义为尚未截止日期且尚未安排的 TODO 标题:在 Emacs Org-Mode 中将未计划的待办事项定义为卡住的项目
  2. Mx org-agenda-list-stuck-projects。这将显示没有截止日期的 TODO 标题列表。
  3. m 标记您要添加截止日期的条目。
  4. B 调用 org-agenda-bulk-action。
  5. d 为所有这些分配一个截止日期。

Another approach is to use org-agenda-bulk-action in org-agenda-mode.

  1. Define stuck-projects as TODO headings that do not yet have a deadline and have not yet been scheduled: Defining unscheduled todos as stuck projects in Emacs Org-Mode
  2. M-x org-agenda-list-stuck-projects. This will display a list of TODO headings with no deadline.
  3. m to mark the entries to which you'd like to add a deadline.
  4. B to invoke org-agenda-bulk-action.
  5. d to assign a single deadline to all of them.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文