From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stuart Hickinbottom Subject: [PATCH] Support for more flexible effort specifications in TaskJuggler exporter Date: Thu, 02 Jun 2011 07:57:47 +0100 Message-ID: <4DE7346B.5010702@hickinbottom.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040709020908040209050505" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:41332) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QS1qr-0004gX-BL for emacs-orgmode@gnu.org; Thu, 02 Jun 2011 02:57:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QS1qq-0006Xx-5J for emacs-orgmode@gnu.org; Thu, 02 Jun 2011 02:57:53 -0400 Received: from lon1-post-1.mail.demon.net ([195.173.77.148]:45451) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QS1qp-0006Xi-Hz for emacs-orgmode@gnu.org; Thu, 02 Jun 2011 02:57:52 -0400 Received: from hickinbottom.demon.co.uk ([80.177.102.168] helo=discovery.hickinbottom.com) by lon1-post-1.mail.demon.net with esmtp (Exim 4.69) id 1QS1qm-00036s-YF for emacs-orgmode@gnu.org; Thu, 02 Jun 2011 06:57:48 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by discovery.hickinbottom.com (Postfix) with ESMTPS id 01817224E3 for ; Thu, 2 Jun 2011 07:57:47 +0100 (BST) 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: Org Mode This is a multi-part message in MIME format. --------------040709020908040209050505 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 --------------040709020908040209050505 Content-Type: text/plain; name="taskjuggler-effort.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="taskjuggler-effort.patch" 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) --------------040709020908040209050505--