From mboxrd@z Thu Jan 1 00:00:00 1970 From: Toby Cubitt Subject: [PATCH] Separate clocksum format for durations >= 1 day Date: Sat, 27 Oct 2012 16:01:56 +0200 Message-ID: <20121027140156.GA5003@c3po> Reply-To: Toby Cubitt Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="WIyZ46R2i8wDzkSu" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:46924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TS73x-0005JY-5X for emacs-orgmode@gnu.org; Sat, 27 Oct 2012 10:08:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TS73v-0003B2-US for emacs-orgmode@gnu.org; Sat, 27 Oct 2012 10:08:33 -0400 Received: from starfish.geekisp.com ([216.168.135.166]:21895) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1TS73v-0003Ay-OW for emacs-orgmode@gnu.org; Sat, 27 Oct 2012 10:08:31 -0400 Content-Disposition: inline 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 --WIyZ46R2i8wDzkSu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Personally, I find the time duration "123:15" much harder to parse mentally than "5d 3:15". The attached patch adds a new customization option `org-time-clocksum-days-format'. When non-nil, this is used instead of `org-time-clocksum-format' for clocksum durations longer than 1 day. It gets passed three values: # days, # hours, # mins. (Note that you don't have to use all three in the format if, say, you don't feel the need to display the minutes for such long durations.) In the patch, I've set the default value for this new customization option to a non-nil value. If you prefer to keep the current behaviour as the default, just make the default value nil. Toby PS: I guess the logical extrapolation of this is to add even more `org-time-clocksum-[months|years|decades]-format' options. (Or, probably better, abandon printf formats for long durations and just add an `org-time-clocksum-format-function' option, leaving it up users to define a function to format the time as they wish.) I haven't done this in the patch, because I think "64d 3:15" is no harder to parse than "2m 4d 3:15" (plus there's the thorny issue of how many days should be in a month). And by the time you get to "535d 3:15" vs. "2y 5d 3:15", the duration is so long that you probably don't care much about the exact value, except that it's a very long-running task indeed! -- Dr T. S. Cubitt Mathematics and Quantum Information group Department of Mathematics Complutense University Madrid, Spain email: tsc25@cantab.net web: www.dr-qubit.org --WIyZ46R2i8wDzkSu Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="0001-Allow-separate-format-for-clocksum-lines-longer-than.patch" >From 2891e0500265df24461d85493e70c1d31c095408 Mon Sep 17 00:00:00 2001 From: "Toby S. Cubitt" Date: Wed, 17 Oct 2012 20:48:41 +0200 Subject: [PATCH] Allow separate format for clocksum lines longer than 1 day. Configured by new org-time-clocksum-days-format customization option. --- lisp/org-colview.el | 7 +++++-- lisp/org.el | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 9d58b5f..244458f 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -1058,8 +1058,11 @@ Don't set this, this is meant for dynamic scoping.") ((memq fmt '(estimate)) (org-estimate-print n printf)) ((not (numberp n)) "") ((memq fmt '(add_times max_times min_times mean_times)) - (let* ((h (floor n)) (m (floor (+ 0.5 (* 60 (- n h)))))) - (format org-time-clocksum-format h m))) + (let* ((h (floor n)) (m (floor (+ 0.5 (* 60 (- n h))))) (d (/ h 24))) + (if (or (= d 0) (null org-time-clocksum-days-format)) + (format org-time-clocksum-format h m) + (setq h (- h (* 24 d))) + (format org-time-clocksum-days-format d h m)))) ((eq fmt 'checkbox) (cond ((= n (floor n)) "[X]") ((> n 1.) "[-]") diff --git a/lisp/org.el b/lisp/org.el index 2aa70bd..2eb65d6 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -2720,6 +2720,12 @@ This is also used when org-mode generates a time duration." :group 'org-time :type 'string) +(defcustom org-time-clocksum-days-format "%dd %d:%02d" + "The format string used for CLOCKSUM lines longer than 1 day. +If null, fall back to `org-time-clocksum-format'." + :group 'org-time + :type '(choice (string :tag "format") (const :tag "disabled" nil))) + (defcustom org-time-clocksum-use-fractional nil "If non-nil, \\[org-clock-display] uses fractional times. org-mode generates a time duration." -- 1.7.8.6 --WIyZ46R2i8wDzkSu--