From mboxrd@z Thu Jan 1 00:00:00 1970 From: Malcolm Matalka Subject: Re: [PATCH] Support time units in est+ Date: Fri, 3 Feb 2017 13:56:36 +0100 Message-ID: References: <861sw0az19.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a113decece6296b05479fcf48 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41781) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZdPs-0000C5-4r for emacs-orgmode@gnu.org; Fri, 03 Feb 2017 07:56:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZdPq-0005G6-FJ for emacs-orgmode@gnu.org; Fri, 03 Feb 2017 07:56:40 -0500 Received: from mail-oi0-x229.google.com ([2607:f8b0:4003:c06::229]:36018) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cZdPq-0005FO-7s for emacs-orgmode@gnu.org; Fri, 03 Feb 2017 07:56:38 -0500 Received: by mail-oi0-x229.google.com with SMTP id u143so10403201oif.3 for ; Fri, 03 Feb 2017 04:56:37 -0800 (PST) In-Reply-To: <861sw0az19.fsf@gmail.com> 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" To: emacs-orgmode@gnu.org --001a113decece6296b05479fcf48 Content-Type: text/plain; charset=UTF-8 Hello, has anyone had an opportunity to review this? Thank you. Den 18 jan. 2017 9:33 em skrev "Malcolm Matalka" : > Hey, this is my first elisp programming so I'm quite certain this is a > big hack. I just stole elements from elsewhere in the file. I'm hoping > this is good enough to get accepted then perhaps someone with more taste > would be able to refactor it to be a bit better. > > Let me know if I need to change anything. > > From 1167bd20e042ad2ae3f2712f596d76ad8b230336 Mon Sep 17 00:00:00 2001 > From: orbitz > Date: Wed, 18 Jan 2017 21:18:23 +0100 > Subject: [PATCH] org-colview.el: Add support for time units to est+ > > * lisp/org-colview.el: Add support for time units in est+. Ranges are > interpreted just like non-range estimates. > > TINYCHANGE > --- > lisp/org-colview.el | 44 ++++++++++++++++++++++++++++++++------------ > 1 file changed, 32 insertions(+), 12 deletions(-) > > diff --git a/lisp/org-colview.el b/lisp/org-colview.el > index 45c71a028..2a5c067ac 100644 > --- a/lisp/org-colview.el > +++ b/lisp/org-colview.el > @@ -1288,23 +1288,43 @@ When PRINTF is non-nil, use it to format the > result." > (/ (apply #'+ (mapcar #'org-columns--age-to-seconds ages)) > (float (length ages))))) > > -(defun org-columns--summary-estimate (estimates printf) > +(defun org-columns--summary-estimate (estimates _) > "Combine a list of estimates, using mean and variance. > The mean and variance of the result will be the sum of the means > and variances (respectively) of the individual estimates." > (let ((mean 0) > - (var 0)) > + (var 0) > + (hms-flag nil) > + (duration-flag nil)) > (dolist (e estimates) > - (pcase (mapcar #'string-to-number (split-string e "-")) > -(`(,low ,high) > - (let ((m (/ (+ low high) 2.0))) > - (cl-incf mean m) > - (cl-incf var (- (/ (+ (* low low) (* high high)) 2.0) (* m m))))) > -(`(,value) (cl-incf mean value)))) > - (let ((sd (sqrt var))) > - (format "%s-%s" > - (format (or printf "%.0f") (- mean sd)) > - (format (or printf "%.0f") (+ mean sd)))))) > + (pcase (split-string e "-") > + (`(,low ,high) > + (dolist (time (list high low)) > + (cond > + (duration-flag) > + ((string-match-p org-columns--duration-re time) > + (setq duration-flag t)) > + (hms-flag) > + ((string-match-p "\\`[0-9]+:[0-9]+:[0-9]+\\'" time) > + (setq hms-flag t)))) > + (let* ((low-sec (org-columns--time-to-seconds low)) > + (high-sec (org-columns--time-to-seconds high)) > + (m (/ (+ low-sec high-sec) 2.0))) > + (cl-incf mean m) > + (cl-incf var (- (/ (+ (* low-sec low-sec) (* high-sec > high-sec)) 2.0) (* m m))))) > + (`(,value) (cl-incf mean (org-columns--time-to-seconds value))))) > + (let* ((sd (sqrt var)) > + (low-second (truncate (- mean sd))) > + (high-second (truncate (+ mean sd))) > + (low > + (cond (duration-flag (org-minutes-to-clocksum-string (/ > low-second 60.0))) > + (hms-flag (format-seconds "%h:%.2m:%.2s" low-second)) > + (t (format-seconds "%h:%.2m" low-second)))) > + (high > + (cond (duration-flag (org-minutes-to-clocksum-string (/ > high-second 60.0))) > + (hms-flag (format-seconds "%h:%.2m:%.2s" high-second)) > + (t (format-seconds "%h:%.2m" high-second))))) > + (format "%s-%s" low high)))) > > > > -- > 2.11.0 > > --001a113decece6296b05479fcf48 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hello, has anyone had an opportunity to review this?=C2= =A0 Thank you.

Den 18 jan. 2017 9:33 em skrev "Malcolm Matalka" <mmatalka@gmail.com>:
Hey, this is my first elisp programm= ing so I'm quite certain this is a
big hack.=C2=A0 I just stole elements from elsewhere in the file.=C2=A0 I&#= 39;m hoping
this is good enough to get accepted then perhaps someone with more taste would be able to refactor it to be a bit better.

Let me know if I need to change anything.

>From 1167bd20e042ad2ae3f2712f596d76ad8b230336 Mon Sep 17 00:00:00 2001=
From: orbitz <orbitz@gmail.com&g= t;
Date: Wed, 18 Jan 2017 21:18:23 +0100
Subject: [PATCH] org-colview.el: Add support for time units to est+

* lisp/org-colview.el: Add support for time units in est+.=C2=A0 Ranges are= interpreted just like non-range estimates.

TINYCHANGE
---
lisp/org-colview.el | 44 ++++++++++++++++++++++++++++++++------------<= br> 1 file changed, 32 insertions(+), 12 deletions(-)

diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index 45c71a028..2a5c067ac 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -1288,23 +1288,43 @@ When PRINTF is non-nil, use it to format the result= ."
=C2=A0 =C2=A0 (/ (apply #'+ (mapcar #'org-columns--age-to-seconds a= ges))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(float (length ages)))))

-(defun org-columns--summary-estimate (estimates printf)
+(defun org-columns--summary-estimate (estimates _)
=C2=A0 =C2=A0"Combine a list of estimates, using mean and variance. The mean and variance of the result will be the sum of the means
=C2=A0and variances (respectively) of the individual estimates."
=C2=A0 =C2=A0(let ((mean 0)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 (var 0))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 (var 0)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 (hms-flag nil)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 (duration-flag nil))
=C2=A0 =C2=A0 =C2=A0(dolist (e estimates)
-=C2=A0 =C2=A0 =C2=A0 (pcase (mapcar #'string-to-number (split-string e= "-"))
-(`(,low ,high)
- (let ((m (/ (+ low high) 2.0)))
-=C2=A0 =C2=A0(cl-incf mean m)
-=C2=A0 =C2=A0(cl-incf var (- (/ (+ (* low low) (* high high)) 2.0) (* m m)= ))))
-(`(,value) (cl-incf mean value))))
-=C2=A0 =C2=A0 (let ((sd (sqrt var)))
-=C2=A0 =C2=A0 =C2=A0 (format "%s-%s"
-=C2=A0 =C2=A0 =C2=A0 (format (or printf "%.0f") (- mean sd))
-=C2=A0 =C2=A0 =C2=A0 (format (or printf "%.0f") (+ mean sd))))))=
+=C2=A0 =C2=A0 =C2=A0 (pcase (split-string e "-")
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 (`(,low ,high)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(dolist (time (list high low))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(cond
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (duration-flag)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ((string-match-p org-columns--du= ration-re time)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq duration-flag t)) +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (hms-flag)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ((string-match-p "\\`[0-9]+= :[0-9]+:[0-9]+\\'" time)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq hms-flag t))))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(let* ((low-sec (org-columns--time-to-se= conds low))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (high-sec (org-col= umns--time-to-seconds high))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (m (/ (+ low-sec h= igh-sec) 2.0)))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(cl-incf mean m)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(cl-incf var (- (/ (+ (* low-sec = low-sec) (* high-sec high-sec)) 2.0) (* m m)))))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 (`(,value) (cl-incf mean (org-columns--time-to= -seconds value)))))
+=C2=A0 =C2=A0 (let* ((sd (sqrt var))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(low-second (truncate (- mean sd)= ))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(high-second (truncate (+ mean sd= )))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(low
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (cond (duration-flag (org-minute= s-to-clocksum-string (/ low-second 60.0)))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (hms-flag (= format-seconds "%h:%.2m:%.2s" low-second))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (t (format-= seconds "%h:%.2m" low-second))))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(high
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (cond (duration-flag (org-minute= s-to-clocksum-string (/=C2=A0 high-second 60.0)))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (hms-flag (= format-seconds "%h:%.2m:%.2s" high-second))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (t (format-= seconds "%h:%.2m" high-second)))))
+=C2=A0 =C2=A0 =C2=A0 (format "%s-%s" low high))))



--
2.11.0

--001a113decece6296b05479fcf48--