emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* compute the difference between effort estimates and actual clocked time
@ 2011-07-31  9:10 M.P.
  2011-08-16 14:25 ` Bastien
  0 siblings, 1 reply; 4+ messages in thread
From: M.P. @ 2011-07-31  9:10 UTC (permalink / raw)
  To: emacs-orgmode

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?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: compute the difference between effort estimates and actual clocked time
  2011-07-31  9:10 compute the difference between effort estimates and actual clocked time M.P.
@ 2011-08-16 14:25 ` Bastien
  2011-08-16 21:04   ` Mattia Pascal
  0 siblings, 1 reply; 4+ messages in thread
From: Bastien @ 2011-08-16 14:25 UTC (permalink / raw)
  To: M.P.; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 958 bytes --]

Hi Pascal,

M.P. <mattia.pascal@gmail.com> 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,


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-New-option-org-properties-postprocess-alist.patch --]
[-- Type: text/x-patch, Size: 2232 bytes --]

From b2cdde739e4ed552b5cd4c30d62fb4215656d603 Mon Sep 17 00:00:00 2001
From: Bastien Guerry <bzg@altern.org>
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


[-- Attachment #3: Type: text/plain, Size: 14 bytes --]


-- 
 Bastien

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: compute the difference between effort estimates and actual clocked time
  2011-08-16 14:25 ` Bastien
@ 2011-08-16 21:04   ` Mattia Pascal
  2011-08-17  9:41     ` Bastien
  0 siblings, 1 reply; 4+ messages in thread
From: Mattia Pascal @ 2011-08-16 21:04 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Thanks a lot. It's what I needed.
I'll work on it.

On Tue, Aug 16, 2011 at 4:25 PM, Bastien <bzg@altern.org> wrote:
> Hi Pascal,
>
> M.P. <mattia.pascal@gmail.com> 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,
>
>
>
> --
>  Bastien
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: compute the difference between effort estimates and actual clocked time
  2011-08-16 21:04   ` Mattia Pascal
@ 2011-08-17  9:41     ` Bastien
  0 siblings, 0 replies; 4+ messages in thread
From: Bastien @ 2011-08-17  9:41 UTC (permalink / raw)
  To: Mattia Pascal; +Cc: emacs-orgmode

Hi Pascal,

Mattia Pascal <mattia.pascal@gmail.com> writes:

> Thanks a lot. It's what I needed.

I've applied the patch, thanks.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-08-17  9:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-31  9:10 compute the difference between effort estimates and actual clocked time M.P.
2011-08-16 14:25 ` Bastien
2011-08-16 21:04   ` Mattia Pascal
2011-08-17  9:41     ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).