On Wed, Nov 09, 2011 at 09:10:57AM +0100, Carsten Dominik wrote:
> On 8.11.2011, at 23:35, Brian van den Broek wrote:
> > On 7 November 2011 16:29, Carsten Dominik
> >> On Nov 7, 2011, at 1:19 PM, Giovanni Ridolfi wrote:
> >>> Fabrizio Chiarello writes:
> >>>> I have many tasks with a DEADLINE, and I wish to have their subtasks
> >>>> inherit such DEADLINE. To this aim, I set:
> >>>> (setq org-use-property-inheritance (quote ("DEADLINE")))
> >>>> The problem is that the agenda only shows deadlines for the tasks
> >>>> define them
> >>> is DEADLINE a property that can be inherited?
> >> Deadlines can currently *not* be inherited. I would probably advice
> >> against implementing this because of performance issues that would
> >> result for the construction of the agenda.
> >> - Carsten
> > Hi all,
> > Here's a thought: what about a function which scans a subtree of an
> > item that has a deadline and adds that same deadline to any
> > descendants that lack a deadline? It seems to me that this would, via
> > a one time user intervention, meet the OP's need, without the constant
> > overhead about which Carsten is concerned.
> This is a good idea and very easy to do.
> The only disadvantage is that any new entries you make
> would not get the deadline. Though, I think, one
> could put a function into org-insert-heading-hook
> to check for a deadline higher up in the tree and copy it.
> - Carsten
> > It further occurred to me that invoked without arguments, it would
> > prompt the user for each item without deadline, with a prefix
> > argument, apply all the deadlines automatically, and, with a numeric
> > prefix n, automatically apply the alterations n-levels down.
> > Best,
> > Brian vdB
I solved by adding the following block in the agenda:
(" " "Agenda"
((org-agenda-overriding-header "Inheritable DEADLINEs")
which shows the tasks without deadline that can inherit a deadline from
one of the parents. Then with the following keys I can set the deadline
of a task to that of the parent directly in the agenda.
(org-defkey org-agenda-mode-map "D" 'fc/org-agenda-inherit-deadline))
The rest of the functions are below
(defun fc/has-inheritable-deadline-p ()
"Any task (without DEADLINE) that can inherit a DEADLINE"
(let ((deadline (org-entry-get nil "DEADLINE"))
(inheritable-deadline (org-entry-get-with-inheritance "DEADLINE")))
(if (org-not-nil deadline)
(if (org-not-nil inheritable-deadline)
(defun fc/skip-non-inheritable-deadlines ()
"Skip tasks that cannot inherit a DEADLINE"
(let* ((next-headline (save-excursion (or (outline-next-heading)
(defun fc/org-inherit-deadline ()
"Inherit a DEADLINE."
(let* ((deadline (org-entry-get-with-inheritance "DEADLINE")))
(if (and (org-not-nil deadline)
(y-or-n-p (format "Inherit DEADLINE: <%s>? " deadline)))
(org-deadline nil (org-time-string-to-time deadline)))))
(defun fc/org-agenda-inherit-deadline (&optional arg)
"Inherit a DEADLINE in agenda."
(let* ((marker (or (org-get-at-bol 'org-marker)
(hdmarker (or (org-get-at-bol 'org-hd-marker)
(pos (marker-position marker))
(org-with-remote-undo (marker-buffer marker)
(with-current-buffer (marker-buffer marker)
(setq newhead (org-get-heading)))
(org-agenda-change-all-lines newhead hdmarker))))
Photonics and Electromagnetics Group
Department of Information Engineering
University of Padova, Italy
Wisdom alone is true ambition's aim, wisdom is the source of virtue and
of fame; obtained with labour, for mankind employed, and then, when most
you share it, best enjoyed.
-- Alfred North Whitehead