Reputation: 3111
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.
Upvotes: 15
Views: 3926
Reputation: 34354
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)
Upvotes: 5
Reputation: 34354
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)
Upvotes: 1
Reputation: 6378
Another approach is to use org-agenda-bulk-action
in org-agenda-mode
.
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 M-x org-agenda-list-stuck-projects
. This will display a list of TODO headings with no deadline.org-agenda-bulk-action
. Upvotes: 0
Reputation: 3111
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
Upvotes: 2
Reputation: 1140
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)
Upvotes: 5
Reputation: 3596
DEADLINE is one of these properties, that are not inherited by default.
You can change that by customizing the variable org-use-property-inheritance
Upvotes: 1