emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Stuart Hickinbottom <stuart@hickinbottom.com>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: [PATCH] Support for more flexible effort specifications in TaskJuggler exporter
Date: Thu, 02 Jun 2011 07:57:47 +0100	[thread overview]
Message-ID: <4DE7346B.5010702@hickinbottom.com> (raw)

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

Firstly thanks to Carsten and the whole community for org-mode - it's
really made a positive impact on my project organisation, project
tracking and record keeping at work.

I've been experimenting with tracking medium-sized tasks in org as a
work-breakdown and exporting to TaskJuggler to see just how many
evenings and weekends I'll have to work to meet my promised deadlines! A
recent patch (patch 638, 6th Match 2011) added support for more flexible
effort estimate properties such as 4h, 3.5d etc.

Unfortunately, at the moment the TaskJuggler exporter is more fussy over
this property and only accepts HH:MM or an integer, both of which it
translates to a number of days when exporting.

The attached patch adds support for passing-through effort
specifications when they're in the form "REAL UNIT" as they are for TJ,
supporting the suffixes d, w, m and y in a consistent way to org.
Support for HH:MM or bare number of days should still work as before. It
also cleans up another couple of things about the export of effort:

- HH:MM produces a floating point days duration now (was previously
rounded to an integer)
- The bare REAL effort regex failed to escape the decimal point (and
would match any char)
- Regexes now anchor to the string start to avoid matching the end of
duff values
- Docstring updated for more flexible effort specification

Apologies for my pidgin Emacs and elisp/regexes - this is my first
org-mode patch. Hopefully I've done it right...

-- 
Stuart


[-- Attachment #2: taskjuggler-effort.patch --]
[-- Type: text/plain, Size: 1592 bytes --]

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index d2e5c1f..8f9174e 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -615,17 +615,19 @@ is defined it will calculate a unique id for the resource using
   "Translate effort strings into a format acceptable to taskjuggler,
 i.e. REAL UNIT. If the effort string is something like 5:30 it
 will be assumed to be hours and will be translated into 5.5h.
-Otherwise if it contains something like 3.0 it is assumed to be
-days and will be translated into 3.0d. Other formats that
-taskjuggler supports (like weeks, months and years) are currently
-not supported."
+TaskJuggler-compatible units are also supported for hours (h),
+days (d), weeks (w), months (m) and years (y) and so effort can
+be specified like 3h or 4.5d.  Otherwise if it contains a bare
+effort without a unit such as 3.0 it is assumed to be days and
+will be translated into 3.0d."
   (cond
    ((null effort) effort)
    ((string-match "\\([0-9]+\\):\\([0-9]+\\)" effort)
     (let ((hours (string-to-number (match-string 1 effort)))
 	  (minutes (string-to-number (match-string 2 effort))))
-      (format "%dh" (+ hours (/ minutes 60.0)))))
-   ((string-match "\\([0-9]+\\).\\([0-9]+\\)" effort) (concat effort "d"))
+      (format "%.1fh" (+ hours (/ minutes 60.0)))))
+   ((string-match "^\\([0-9]+\\)\\(\\.\\([0-9]+\\)\\)?\\([hdwmy]\\)$" effort) effort)
+   ((string-match "^\\([0-9]+\\)\\.\\([0-9]+\\)$" effort) (concat effort "d"))
    (t (error "Not a valid effort (%s)" effort))))
 
 (defun org-taskjuggler-get-priority (priority)

             reply	other threads:[~2011-06-02  6:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-02  6:57 Stuart Hickinbottom [this message]
2011-06-08 15:27 ` [PATCH] Support for more flexible effort specifications in TaskJuggler exporter Christian Egli

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=4DE7346B.5010702@hickinbottom.com \
    --to=stuart@hickinbottom.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).