From: Nicolas Goaziou <n.goaziou@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Separate clocksum format for durations >= 1 day
Date: Tue, 06 Nov 2012 11:57:25 +0100 [thread overview]
Message-ID: <878vaf9ey2.fsf@gmail.com> (raw)
In-Reply-To: <20121106103546.GA9407@c3po> (Toby Cubitt's message of "Tue, 6 Nov 2012 11:35:46 +0100")
Toby Cubitt <tsc25@cantab.net> writes:
>> 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.
Actually the number of functions defined doesn't matter much. What
matters is the number of functions exposed to the end-user, which is
0 in this situation (or 1 if he decides to write his own). Here, all is
solved with one defcustom.
You don't even need to create multiple functions for that. The defcustom
can store `regular', `decimal' symbols or a function. Then you can write
a generic duration format function that will be used across code base
with the following template:
#+begin_src emacs-lisp
(defun org-build-format-duration (n)
"Format duration N according to `org-duration-format' variable.
N is the duration to display, as a number, expressed in minutes.
Return formatted duration as a string."
(cond ((functionp org-duration-format) (funcall org-duration-format))
((eq org-duration-format 'regular) ...)
((eq org-duration-format 'decimal) ...)
(t (error "Invalid `org-duration-format' value"))))
#+end_src
One variable exposed to the user. One function exposed to the developer.
It's much simpler.
Regards,
--
Nicolas Goaziou
next prev parent reply other threads:[~2012-11-06 11:01 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878vaf9ey2.fsf@gmail.com \
--to=n.goaziou@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).