From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Ecay Subject: Re: [PATCH 3/9] org-clock: fix `org-clock-time%' Date: Wed, 04 Nov 2015 11:18:44 +0000 Message-ID: <87oafavwq3.fsf@gmail.com> References: <1446581747-1960-1-git-send-email-oxij@oxij.org> <1446581747-1960-4-git-send-email-oxij@oxij.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ztw5g-0008P9-9O for emacs-orgmode@gnu.org; Wed, 04 Nov 2015 06:19:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ztw5W-0000wG-NJ for emacs-orgmode@gnu.org; Wed, 04 Nov 2015 06:18:56 -0500 Received: from mail-wi0-x235.google.com ([2a00:1450:400c:c05::235]:37637) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ztw5W-0000vS-Ey for emacs-orgmode@gnu.org; Wed, 04 Nov 2015 06:18:46 -0500 Received: by wicfv8 with SMTP id fv8so29998944wic.0 for ; Wed, 04 Nov 2015 03:18:45 -0800 (PST) In-Reply-To: <1446581747-1960-4-git-send-email-oxij@oxij.org> 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: Jan Malakhovski Hi Jan, A couple stylistic comments. 2015ko azaroak 3an, Jan Malakhovski-ek idatzi zuen: >=20 > * lisp/org-clock.el (org-clock-time%): Respect org-effort-durations. >=20 > This also fixes a bug with time percents looking pretty much random and a= dding > to a number that is less than 100% when a clock report has long intervals > (e.g. days). > --- > lisp/org-clock.el | 29 +++++++++++------------------ > 1 file changed, 11 insertions(+), 18 deletions(-) >=20 > diff --git a/lisp/org-clock.el b/lisp/org-clock.el > index ad423f1..4563a8a 100644 > --- a/lisp/org-clock.el > +++ b/lisp/org-clock.el > @@ -2867,27 +2867,20 @@ TIME: The sum of all time spend in this tree= , in minutes. This time >=20=20 > (defun org-clock-time% (total &rest strings) > "Compute a time fraction in percent. > -TOTAL s a time string like 10:21 specifying the total times. > +TOTAL s a total time string. > STRINGS is a list of strings that should be checked for a time. > -The first string that does have a time will be used. > -This function is made for clock tables." > - (let ((re "\\([0-9]+\\):\\([0-9]+\\)") > - tot s) > - (save-match-data > +Strings are parsed using `org-duration-string-to-minutes`. > +The first string that does have a time will be used. This > +function is made for clock tables." > + (save-match-data > + (let (tot s cur) > (catch 'exit > - (if (not (string-match re total)) > - (throw 'exit 0.) > - (setq tot (+ (string-to-number (match-string 2 total)) > - (* 60 (string-to-number (match-string 1 total))))) > - (if (=3D tot 0.) (throw 'exit 0.))) > + (setq tot (org-duration-string-to-minutes total)) > + (if (=3D tot 0.) (throw 'exit 0.)) > (while (setq s (pop strings)) This could be converted to dolist while you=E2=80=99re here (I realize you didn=E2=80=99t touch this line). > - (if (string-match "\\([0-9]+\\):\\([0-9]+\\)" s) > - (throw 'exit > - (/ (* 100.0 (+ (string-to-number (match-string 2 s)) > - (* 60 (string-to-number > - (match-string 1 s))))) > - tot)))) > - 0)))) > + (setq cur (org-clocksum-string-to-minutes s)) > + (if (not (equal cur nil)) (throw 'exit (/ (* 100.0 cur) tot)))) (when cur (throw 'exit ...)) --=20 Aaron Ecay