emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Separate clocksum format for durations >= 1 day
@ 2012-10-27 14:01 Toby Cubitt
  2012-11-05  9:14 ` Nicolas Goaziou
  0 siblings, 1 reply; 43+ messages in thread
From: Toby Cubitt @ 2012-10-27 14:01 UTC (permalink / raw)
  To: emacs-orgmode

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

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

[-- Attachment #2: 0001-Allow-separate-format-for-clocksum-lines-longer-than.patch --]
[-- Type: text/x-patch, Size: 1883 bytes --]

From 2891e0500265df24461d85493e70c1d31c095408 Mon Sep 17 00:00:00 2001
From: "Toby S. Cubitt" <tsc25@cantab.net>
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


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

end of thread, other threads:[~2012-11-30 11:22 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-27 14:01 [PATCH] Separate clocksum format for durations >= 1 day Toby Cubitt
2012-11-05  9:14 ` Nicolas Goaziou
2012-11-05 10:25   ` Toby Cubitt
2012-11-05 10:47   ` Achim Gratz
2012-11-05 11:01     ` Toby Cubitt
2012-11-05 11:13       ` Achim Gratz
2012-11-05 12:10         ` Toby Cubitt
2012-11-05 12:20           ` Nicolas Goaziou
2012-11-05 12:55             ` Toby Cubitt
2012-11-05 13:14               ` Nicolas Goaziou
2012-11-05 17:40                 ` Achim Gratz
2012-11-05 18:16                   ` Toby Cubitt
2012-11-05 22:45                     ` Nicolas Goaziou
2012-11-06 10:35                       ` Toby Cubitt
2012-11-06 10:57                         ` Nicolas Goaziou
2012-11-06 12:01                           ` Toby Cubitt
2012-11-06 12:29                             ` Nicolas Goaziou
2012-11-06 13:04                               ` Toby Cubitt
2012-11-06 17:41                                 ` Nicolas Goaziou
2012-11-06 19:26                                   ` Toby Cubitt
2012-11-06 19:55                                     ` Nicolas Goaziou
2012-11-06 20:35                                       ` Toby Cubitt
2012-11-08  0:26                                         ` Nicolas Goaziou
2012-11-08 11:28                                           ` Toby Cubitt
2012-11-09  8:04                                             ` Nicolas Goaziou
2012-11-13 13:03                                               ` Toby Cubitt
2012-11-14 15:04                                                 ` Nicolas Goaziou
2012-11-14 15:37                                                   ` Toby Cubitt
2012-11-14 16:09                                                     ` Nicolas Goaziou
2012-11-14 16:20                                                       ` Toby Cubitt
2012-11-16 15:12                                                         ` Toby Cubitt
2012-11-17  8:48                                                           ` Nicolas Goaziou
2012-11-17 14:00                                                             ` Toby Cubitt
2012-11-17 14:42                                                               ` Nicolas Goaziou
2012-11-17 16:02                                                                 ` Toby Cubitt
2012-11-20 16:12                                                                   ` Mike McLean
2012-11-20 17:28                                                                     ` Toby Cubitt
2012-11-20 19:24                                                                       ` Nicolas Goaziou
2012-11-21 23:29                                                                         ` Mike McLean
2012-11-30 11:22                                                                 ` [bug] " Sebastien Vauban
2012-11-06 18:42                       ` [PATCH] " Achim Gratz
2012-11-06 20:10                         ` Toby Cubitt
2012-11-06 20:49                           ` Achim Gratz

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).