From mboxrd@z Thu Jan 1 00:00:00 1970 From: Malcolm Matalka Subject: Re: [PATCH] Support time units in est+ Date: Thu, 19 Jan 2017 05:49:57 +0100 Message-ID: References: <861sw0az19.fsf@gmail.com> <87eg00ystv.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a1142cee6e2454005466b4330 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52366) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cU4fg-00053t-Gb for emacs-orgmode@gnu.org; Wed, 18 Jan 2017 23:50:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cU4fe-0000Nn-Up for emacs-orgmode@gnu.org; Wed, 18 Jan 2017 23:50:00 -0500 Received: from mail-ot0-x236.google.com ([2607:f8b0:4003:c0f::236]:36352) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cU4fe-0000NP-NO for emacs-orgmode@gnu.org; Wed, 18 Jan 2017 23:49:58 -0500 Received: by mail-ot0-x236.google.com with SMTP id 104so24182174otd.3 for ; Wed, 18 Jan 2017 20:49:58 -0800 (PST) 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" To: Nick Dokos Cc: emacs-orgmode@gnu.org --001a1142cee6e2454005466b4330 Content-Type: text/plain; charset=UTF-8 Den 18 jan. 2017 22:19 skrev "Nick Dokos" : Malcolm Matalka writes: > 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. > Yes, indeed: the first thing you should do is explain what you are trying to do. E.g. what does "est+" mean? Once you have explained *what* you are trying to do, then somebody might be able to suggest *how* to do it better (if it is a worthwhile thing to do in the first place). I'm not sure I understand your question. est+ is an existing functionality in columnview that is documented. I've brought it closer to the regular effort functionality by supporting time units. > 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)))) -- Nick --001a1142cee6e2454005466b4330 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


Den 18 jan. 2017 22:19 skrev "Nick Dokos" <ndokos@gmail.com>:
Malcolm Matalka <= ;mmatalka@gmail.com> writes:
> Hey, this is my first elisp programming so I'm quite certain this = is a
> big hack.=C2=A0 I just stole elements from elsewhere in the file.=C2= =A0 I'm hoping
> this is good enough to get accepted then perhaps someone with more tas= te
> would be able to refactor it to be a bit better.
>
> Let me know if I need to change anything.
>

Yes, indeed: the first thing you should do is explain what you are trying to do.=C2=A0 E.g. what does "est+" mean? Once you have exp= lained
*what* you are trying to do, then somebody might be able to suggest
*how* to do it better (if it is a worthwhile thing to do in the first place= ).

I'm not sure I understand your question. =C2=A0est+ is an exi= sting functionality in columnview that is documented. I've brought it c= loser to the regular effort functionality by supporting time units.


> From 1167bd20e042ad2ae3f2712f596d76ad8b230336 Mon Sep 17 00:00:00= 2001
> From: orbitz <orbitz@gmail.com<= /a>>
> 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 Range= s 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 r= esult."
>=C2=A0 =C2=A0 =C2=A0(/ (apply #'+ (mapcar #'org-columns--age-to= -seconds ages))
>=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 varianc= e.
> The mean and variance of the result will be the sum of the means
>=C2=A0 and variances (respectively) of the individual estimates."<= br> >=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-str= ing 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-column= s--duration-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))))<= br> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(let* ((low-sec (org-columns--time-= to-seconds low))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (high-sec (or= g-columns--time-to-seconds high))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (m (/ (+ low-= sec high-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--ti= me-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 (- mea= n sd)))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(high-second (truncate (+ me= an 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-m= inutes-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-f= lag (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 (fo= rmat-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-m= inutes-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-f= lag (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 (fo= rmat-seconds "%h:%.2m" high-second)))))
> +=C2=A0 =C2=A0 =C2=A0 (format "%s-%s" low high))))

--
Nick



--001a1142cee6e2454005466b4330--