From: Bastien Guerry <bzg@altern.org>
To: emacs-orgmode@gnu.org
Subject: [Accepted] [O] Support modifiers in effort durations (was: Re: Does Effort support hours only?)
Date: Sun, 6 Mar 2011 18:45:30 +0100 (CET) [thread overview]
Message-ID: <20110306174530.C4F426A27@myhost.localdomain> (raw)
In-Reply-To: m3tyfo1j16.fsf@e4300lm.epcc.ed.ac.uk
Patch 638 (http://patchwork.newartisans.com/patch/638/) is now "Accepted".
Maintainer comment: none
This relates to the following submission:
http://mid.gmane.org/%3Cm3tyfo1j16.fsf%40e4300lm.epcc.ed.ac.uk%3E
Here is the original message containing the patch:
> Content-Type: text/plain; charset="utf-8"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Subject: [O] Support modifiers in effort durations (was: Re: Does Effort
> support hours only?)
> Date: Mon, 28 Feb 2011 16:43:33 -0000
> From: Lawrence Mitchell <wence@gmx.li>
> X-Patchwork-Id: 638
> Message-Id: <m3tyfo1j16.fsf@e4300lm.epcc.ed.ac.uk>
> To: Luke Crook <luke@balooga.com>
> Cc: emacs-orgmode@gnu.org, =?utf-8?Q?S=C3=A9bastien?= Vauban
> <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org>
>
> Luke Crook wrote:
> > Is it possible to specify estimated effort in something other
> > than hours (0.5, or 0:30)?
>
> > For example 1w, 1m, 2d etc?
>
> Here's a cleaned up patch that allows user-specified modifiers
> for effort strings. The new variable `org-effort-durations'
> lists modifiers, and their mapping to minutes (words, as well as
> single-letter modifiers, are supported). The default value is:
>
> (("h" . 60)
> ("d" . 480) ; 8 hours
> ("w" . 2400) ; five days
> ("m" . 9600) ; 4 weeks
> ("y" . 96000)) ; 40 weeks
>
> But you can change this.
>
> Old effort strings (HH:MM) are still interpreted correctly. See
> the docstrings of `org-effort-durations' and
> `org-duration-string-to-minutes' for more details.
>
> >From a0e24b14755eb4087d9c47bb4eea11eb9151efcf Mon Sep 17 00:00:00 2001
> From: Lawrence Mitchell <wence@gmx.li>
> Date: Fri, 18 Feb 2011 11:01:46 +0000
> Subject: [PATCH] Allow human-readable effort durations
> To: emacs-orgmode@gnu.org
>
> * lisp/org.el (org-effort-durations): New variable.
> * lisp/org.el (org-duration-string-to-minutes): New function.
> * lisp/org-agenda.el (org-agenda-filter-effort-form)
> (org-format-agenda-item): Use it.
> * lisp/org-clock.el (org-clock-notify-once-if-expired)
> (org-clock-modify-effort-estimate, org-clock-get-clock-string): Use it.
>
> Specifying large effort durations in hours and minutes is difficult.
> Is 130:25 more than two weeks effort? More than three? This patch
> allows specification of an effort duration as a friendly string. For
> example 2w 5d is two weeks and five days of effort. Existing H:MM
> entries will still be recognised correctly.
>
> ---
> lisp/org-agenda.el | 4 ++--
> lisp/org-clock.el | 8 ++++----
> lisp/org.el | 41 +++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 47 insertions(+), 6 deletions(-)
>
> diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
> index dee23e0..87602dc 100644
> --- a/lisp/org-agenda.el
> +++ b/lisp/org-agenda.el
> @@ -5334,7 +5334,7 @@ Any match of REMOVE-RE will be removed from TXT."
> (get-text-property 0 'org-marker txt)))
> (error nil)))
> (when effort
> - (setq neffort (org-hh:mm-string-to-minutes effort)
> + (setq neffort (org-duration-string-to-minutes effort)
> effort (setq effort (concat "[" effort "]" )))))
>
> (when remove-re
> @@ -6061,7 +6061,7 @@ E looks like \"+<2:25\"."
> ((equal op ??) op)
> (t '=)))
> (list 'org-agenda-compare-effort (list 'quote op)
> - (org-hh:mm-string-to-minutes e))))
> + (org-duration-string-to-minutes e))))
>
> (defun org-agenda-compare-effort (op value)
> "Compare the effort of the current line with VALUE, using OP.
> diff --git a/lisp/org-clock.el b/lisp/org-clock.el
> index 6b45ca5..cc11f3c 100644
> --- a/lisp/org-clock.el
> +++ b/lisp/org-clock.el
> @@ -487,7 +487,7 @@ If not, show simply the clocked time like 01:50."
> (m (- clocked-time (* 60 h))))
> (if org-clock-effort
> (let* ((effort-in-minutes
> - (org-hh:mm-string-to-minutes org-clock-effort))
> + (org-duration-string-to-minutes org-clock-effort))
> (effort-h (floor effort-in-minutes 60))
> (effort-m (- effort-in-minutes (* effort-h 60)))
> (work-done-str
> @@ -561,10 +561,10 @@ the mode line."
> ;; A string. See if it is a delta
> (setq sign (string-to-char value))
> (if (member sign '(?- ?+))
> - (setq current (org-hh:mm-string-to-minutes current)
> + (setq current (org-duration-string-to-minutes current)
> value (substring value 1))
> (setq current 0))
> - (setq value (org-hh:mm-string-to-minutes value))
> + (setq value (org-duration-string-to-minutes value))
> (if (equal ?- sign)
> (setq value (- current value))
> (if (equal ?+ sign) (setq value (+ current value)))))
> @@ -581,7 +581,7 @@ the mode line."
> "Show notification if we spent more time than we estimated before.
> Notification is shown only once."
> (when (org-clocking-p)
> - (let ((effort-in-minutes (org-hh:mm-string-to-minutes org-clock-effort))
> + (let ((effort-in-minutes (org-duration-string-to-minutes org-clock-effort))
> (clocked-time (org-clock-get-clocked-time)))
> (if (setq org-task-overrun
> (if (or (null effort-in-minutes) (zerop effort-in-minutes))
> diff --git a/lisp/org.el b/lisp/org.el
> index 03f0b72..9cf1c94 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -15499,6 +15499,47 @@ If no number is found, the return value is 0."
> (string-to-number (match-string 1 s)))
> (t 0)))
>
> +(defcustom org-effort-durations
> + `(("h" . 60)
> + ("d" . ,(* 60 8))
> + ("w" . ,(* 60 8 5))
> + ("m" . ,(* 60 8 5 4))
> + ("y" . ,(* 60 8 5 40)))
> + "Conversion factor to minutes for an effort modifier.
> +
> +Each entry has the form (MODIFIER . MINUTES).
> +
> +In an effort string, a number followed by MODIFIER is multiplied
> +by the specified number of MINUTES to obtain an effort in
> +minutes.
> +
> +For example, if the value of this variable is ((\"hours\" . 60)), then an
> +effort string \"2hours\" is equivalent to 120 minutes."
> + :group 'org-agenda
> + :type '(alist :key-type (string :tag "Modifier")
> + :value-type (number :tag "Minutes")))
> +
> +(defun org-duration-string-to-minutes (s)
> + "Convert a duration string S to minutes.
> +
> +A bare number is interpreted as minutes, modifiers can be set by
> +customizing `org-effort-durations' (which see).
> +
> +Entries containing a colon are interpreted as H:MM by
> +`org-hh:mm-string-to-minutes'."
> + (let ((result 0)
> + (regex (rx-to-string (group (1+ (any "0-9")))
> + (0+ (syntax whitespace))
> + (group
> + (eval (cons 'or
> + (mapcar 'car org-effort-durations)))))))
> + (while (string-match regex s)
> + (incf result (* (cdr (assoc (match-string 2 s) org-effort-durations))
> + (string-to-number (match-string 1 s))))
> + (setq s (replace-match "" nil t s)))
> + (incf result (org-hh:mm-string-to-minutes s))
> + result))
> +
> ;;;; Files
>
> (defun org-save-all-org-buffers ()
>
next prev parent reply other threads:[~2011-03-06 17:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-17 19:47 Does Effort support hours only? Luke Crook
2011-02-18 9:02 ` Bastien
2011-02-18 9:48 ` Sébastien Vauban
2011-02-18 10:51 ` Lawrence Mitchell
2011-02-18 22:40 ` Herbert Sitz
2011-02-21 9:47 ` Lawrence Mitchell
2011-02-28 11:43 ` [PATCH] Support modifiers in effort durations (was: Re: Does Effort support hours only?) Lawrence Mitchell
2011-03-06 17:45 ` Bastien Guerry [this message]
2011-03-06 17:47 ` [PATCH] Support modifiers in effort durations Bastien
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=20110306174530.C4F426A27@myhost.localdomain \
--to=bzg@altern.org \
--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).