From mboxrd@z Thu Jan 1 00:00:00 1970 From: Toby Cubitt Subject: Re: [PATCH] Separate clocksum format for durations >= 1 day Date: Tue, 6 Nov 2012 11:35:46 +0100 Message-ID: <20121106103546.GA9407@c3po> References: <87y5ifacu3.fsf@gmail.com> Reply-To: Toby Cubitt Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([208.118.235.92]:40731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TVgVK-0000X8-KX for emacs-orgmode@gnu.org; Tue, 06 Nov 2012 05:35:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TVgVI-0005xg-Jh for emacs-orgmode@gnu.org; Tue, 06 Nov 2012 05:35:34 -0500 Received: from starfish.geekisp.com ([216.168.135.166]:28146) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1TVgVI-0005xa-F8 for emacs-orgmode@gnu.org; Tue, 06 Nov 2012 05:35:32 -0500 Content-Disposition: inline In-Reply-To: <87y5ifacu3.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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org On Mon, Nov 05, 2012 at 11:45:24PM +0100, Nicolas Goaziou wrote: > Toby Cubitt writes: > >> This is not far from your own suggestion to provide different functions > >> depending on which output is desired, I just happen to think that these > >> functions would all be so similar that they should be rolled into a > >> single function that can produce different outputs. I think there'd > >> only be a handful of possible values for fmt based on the current usage > >> and that suggests just another cond form would be needed in > >> implementing this function rather than a full-blown format string > >> interpreter. > > > > It seems to me your `org--format-time' function would end up looking very > > like what I sketched. A cond to switch between "hh:mm", "hh.mm", > > "dd hh:mm" or "dd hh.mm" based only on the contents of the fmt argument > > would have to check whether fmt contains 2 or 3 %-sequences, then check > > if it contains "." or ":" > > Again, these are strange and very limiting rules. What if I want to > have "5 h 32 min"? And "5,3 days"? Good point. > Achim didn't specify how he conceives the FMT argument. One possibility > would be to have a placeholder-based template with, i.e. %d, %h, %m, %w > for respectively number of days, hours, minutes and weeks. But it's > still less flexible than functions because you need to have a fixed > number of placeholders in every template. Indeed. None of the format-only proposals would let me reproduce the setup I have currently (with my earlier patch): "5d 3h" for durations longer than a day, "3:15" for durations shorter than a day. > I still think functions are the way to go. Three options in the > defcustom: > > - One to provide regular time (i.e 14:40 or 3d 18:32) > > - One to provide decimal time with the highest unit available (i.e. > 18,75 h or 2,5 d). > > - One free slot for an user-defined function. I like the flexibility of functions. But one drawback of this is that you can't produce your "5 h 32 min" or "5,3 days" examples without defining a new function. It would be nice if tweaking just the format (without changing the numbers themselves) could be done by changing a simple format string. Because the number of placeholders in a format string is fixed, I don't see how to avoid the need for multiple format strings. Perhaps we need a second defcustom that holds a list of format strings, to be used by the functions in your first two choices. The first format string for durations < 1 day (or for all durations if this is the only string in the list), the second for durations >= 1 day. One nice thing is that this could easily be extended in the obvious way if one wanted to allow different formats for durations >= 1 month or >= 1 year. It's slightly ugly that the defaults for the format-string defcustom would have to change depending on the value of the function defcustom. I guess one could either have the format-string defcustom default to nil, and use hard-coded defaults in the functions (which are overridden by a non-nil format string value). Or put both functions and format strings into a single defcustom, e.g. as a list with the function in the first element. Best, Toby -- 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