From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [ANN] New Org duration library Date: Wed, 22 Feb 2017 20:01:17 +0100 Message-ID: <87k28if3sy.fsf@nicolasgoaziou.fr> References: <87bmu6p4f5.fsf@nicolasgoaziou.fr> <87h93nxxs4.fsf@Rainer.invalid> <8760k3toq2.fsf@nicolasgoaziou.fr> <87a89etf2y.fsf@trex> 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]:37007) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcAE-0004ts-0i for emacs-orgmode@gnu.org; Wed, 22 Feb 2017 14:01:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgcAD-0004y8-00 for emacs-orgmode@gnu.org; Wed, 22 Feb 2017 14:01:22 -0500 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]:47882) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgcAC-0004wF-Pp for emacs-orgmode@gnu.org; Wed, 22 Feb 2017 14:01:20 -0500 In-Reply-To: <87a89etf2y.fsf@trex> (Aaron Ecay's message of "Wed, 22 Feb 2017 15:33:57 +0000") 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" To: Achim Gratz Cc: emacs-orgmode@gnu.org Hello, Aaron Ecay writes: > I had a few questions/comments though: > > - Given that the smallest unit of duration is the minute, The base unit is the minute, but nobody prevents you from adding a smaller unit: (let ((org-duration-units (cons `("s" . ,(/ 1 60.0)) org-duration-units))) (org-duration-from-minutes 1.5 '(("min") ("s")))) =3D> "1min 30s" > why are seconds a choice in h:mm:ss? Won=CA=BCt they always be zero? Internally, durations are floats because of seconds. (org-duration-from-minutes 1.5 'h:mm:ss) =3D> "0:01:30" > Maybe it is > better not to offer this choice; I think it is potentially confusing > (giving the impression that durations might be accurate to the > second). Durations _can_ be accurate to the second. This library can be used outside clocksum computations, which are, indeed, accurate only to the minute. > - I would remove the h:mm symbol shorthand. It can still be offered as > a convenient option in customize using (const :tag "Use H:MM" (special > . h:mm)), but making it a special value with its own semantics makes > the system harder to understand for those who write their config in > lisp (rather than using customize). Using a list means you want to use special units to display the duration. However when the value is '((special . h:mm)), there is no unit to display the duration with, so '((special . h:mm)) is the degenerate case, not `h:mm'. Mind you, I'm not opposed to removing `h:mm'. I'm just pointing out the rational behind the initial choice. Moreover, if we remove `h:mm', we need to replace calls like (org-duration-from-minutes 120 'h:mm) with (org-duration-from-minutes 120 '((special . h:mm))) which is slightly uglier. > - The fact that the special options are grouped under the key =E2=80=9Csp= ecial=E2=80=9D > is a bit confusing. If it isn=CA=BCt too much work, I would recommend > restructuring the options slightly to be (use-h:mm . t) and (precision > . INT). This more closely matches my intuition about how alists like > this are used. I chose `special' for a reason: these options are mutually exclusive. Using the same key, the structure (i.e., the alist) makes them mutually exclusive, too. With your suggestion, however, nothing prevents an user to have '((use-h:mm . t) (precision . 2)) and complain if strange things happen. So, I'd rather keep the same car. I'm not married to `special' though. > - Must the list be in decreasing order of unit size, or does everything > work if it=CA=BCs in arbitrary order? The documentation doesn=CA=BCt m= ake it > clear one way or the other. There is no restriction about the order. > The value should be a list of entries each following this pattern: > > (UNIT . REQUIRED) I'd favor REQUIRED? over REQUIRED because it is a boolean. > UNIT is one of the unit strings defined in `org-duration-units'. A > duration is formatted using only the time components that are specified > here. If a time unit in missing, formatting falls back to the next > smallest unit. The algorithm works the other way: it consider biggest units first (greedy algorithm). > At the end of the list, there can be an entry indicating special formatti= ng "The end of the list" is not accurate. The entry can be anywhere. Also, I reworded that part already in master. You may want to have a look at it. Regards, --=20 Nicolas Goaziou 0x80A93738