From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: compute the difference between effort estimates and actual clocked time Date: Tue, 16 Aug 2011 16:25:08 +0200 Message-ID: <87obzpo0o1.fsf@altern.org> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:58265) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QtLDs-0001MZ-CU for emacs-orgmode@gnu.org; Tue, 16 Aug 2011 11:06:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QtLDq-0002kt-0B for emacs-orgmode@gnu.org; Tue, 16 Aug 2011 11:06:32 -0400 Received: from mail-ww0-f49.google.com ([74.125.82.49]:55140) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QtLDp-0002kf-QJ for emacs-orgmode@gnu.org; Tue, 16 Aug 2011 11:06:29 -0400 Received: by wwf10 with SMTP id 10so4727437wwf.30 for ; Tue, 16 Aug 2011 08:06:29 -0700 (PDT) In-Reply-To: (M. P.'s message of "Sun, 31 Jul 2011 09:10:51 +0000 (UTC)") 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: "M.P." Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Hi Pascal, M.P. writes: > I'd like to add to my tasks a property whose value should be the difference in > time between the effort estimates and the actual clocked time. The final purpose > is to use the property in column view mode as I do with CLOCKSUM and Effort. > Could you give me any hints? There is no way to do this easily right now. However, this command will display the remaining effort: #+begin_src emacs-lisp (defun my-org-display-remaining-effort () "Compute remaining effort for current subtree." (interactive) (let ((clocksum (org-clock-sum-current-item)) (effort (org-duration-string-to-minutes (org-entry-get (point) "Effort")))) (message (org-minutes-to-hh:mm-string (- effort clocksum))))) #+end_src Also, the attached patch allow to postprocess property values with custom functions when inserting them with org-set-properties. Let me know if you find this useful! Best, --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-New-option-org-properties-postprocess-alist.patch >From b2cdde739e4ed552b5cd4c30d62fb4215656d603 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 16 Aug 2011 16:21:31 +0200 Subject: [PATCH] New option `org-properties-postprocess-alist'. * org.el (org-properties-postprocess-alist): New option to allow postprocessing the values of properties set through `org-set-property'. (org-set-property): Use this option. This is inspired by a request from Pascal Mattia. --- lisp/org.el | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 318339a..dbefab1 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -2967,6 +2967,28 @@ lined-up with respect to each other." :group 'org-properties :type 'string) +(defcustom org-properties-postprocess-alist nil + "Alist of properties and functions to adjust inserted values. +Elements of this alist must be of the form + + ([string] [function]) + +where [string] must be a property name and [function] must be a +lambda expression: this lambda expression must take one argument, +the value to adjust, and return the new value as a string. + +For example, this element will allow the property \"Remaining\" +to be updated wrt the relation between the \"Effort\" property +and the clock summary: + + ((\"Remaining\" (lambda(value) + (let ((clocksum (org-clock-sum-current-item)) + (effort (org-duration-string-to-minutes + (org-entry-get (point) \"Effort\")))) + (org-minutes-to-hh:mm-string (- effort clocksum))))))" + :group 'org-properties + :type 'alist) + (defcustom org-use-property-inheritance nil "Non-nil means properties apply also for sublevels. @@ -14228,6 +14250,9 @@ in the current file." (let* ((property (or property (org-read-property-name))) (value (or value (org-read-property-value property)))) (setq org-last-set-property property) + ;; Possibly postprocess the inserted value: + (when (assoc property org-properties-postprocess-alist) + (setq value (funcall (cadr fn) value))) (unless (equal (org-entry-get nil property) value) (org-entry-put nil property value)))) -- 1.7.5.2 --=-=-= Content-Type: text/plain -- Bastien --=-=-=--