From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fabrizio Chiarello Subject: Re: View inherited DEADLINEs in agenda Date: Mon, 14 Nov 2011 14:38:27 +0100 Message-ID: <20111114133827.GA7282@hydrogen.black.hole> References: <20111107120311.GA6246@hydrogen.black.hole> <834nygktvh.fsf@yahoo.it> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([140.186.70.92]:48760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RPwk5-0007B1-UQ for emacs-orgmode@gnu.org; Mon, 14 Nov 2011 08:38:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RPwk4-0006fs-4s for emacs-orgmode@gnu.org; Mon, 14 Nov 2011 08:38:33 -0500 Received: from mail2.dei.unipd.it ([147.162.2.112]:55915 helo=mail.dei.unipd.it) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1RPwk3-0006bf-QK for emacs-orgmode@gnu.org; Mon, 14 Nov 2011 08:38:32 -0500 Content-Disposition: inline In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Cc: Brian van den Broek , Carsten Dominik 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 wrote: > >> > >> 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 to > >>>> 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 that > >>>> 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: ;;; (setq org-agenda-custom-commands '( ... (" " "Agenda" ( ... (todo "TODO|CANCELLED|NEXT|STARTED|WAITING|HOLD" ((org-agenda-overriding-header "Inheritable DEADLINEs") (org-agenda-skip-function 'fc/skip-non-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. ;;; (add-hook 'org-agenda-mode-hook (lambda () (org-defkey org-agenda-mode-map "D" 'fc/org-agenda-inherit-deadline)) 'append) ;;; 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) nil (if (org-not-nil inheritable-deadline) t nil)))) (defun fc/skip-non-inheritable-deadlines () "Skip tasks that cannot inherit a DEADLINE" (let* ((next-headline (save-excursion (or (outline-next-heading) (point-max))))) (if (fc/has-inheritable-deadline-p) nil next-headline))) (defun fc/org-inherit-deadline () "Inherit a DEADLINE." (interactive) (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." (interactive "P") (let* ((marker (or (org-get-at-bol 'org-marker) (org-agenda-error))) (hdmarker (or (org-get-at-bol 'org-hd-marker) marker)) (pos (marker-position marker)) newhead) (org-with-remote-undo (marker-buffer marker) (with-current-buffer (marker-buffer marker) (widen) (goto-char pos) (org-show-context 'agenda) (org-show-entry) (org-cycle-hide-drawers 'children) (fc/org-inherit-deadline) (setq newhead (org-get-heading))) (org-agenda-change-all-lines newhead hdmarker)))) ;;; -- Fabrizio Chiarello 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