[O] [PATCH] org.el: Use normalized names in org-agenda-file-p

2014-10-12 Thread Yann Hodique
Hi,

attached is a patch that fixes a bug where `org-agenda-file-p' doesn't
recognize files when, for example, `org-agenda-files' contains entries
that involve symlinks.

Thanks

Yann

-- 
Seek freedom and become captive of your desires.
Seek discipline and find your liberty.

  -- The Coda
From 5cf4603cfacd3fb2a3569ed2ea14081631a11024 Mon Sep 17 00:00:00 2001
From: Yann Hodique yann.hodi...@gmail.com
Date: Sun, 12 Oct 2014 08:42:04 -0700
Subject: [PATCH] org.el: Use normalized names in org-agenda-file-p

* lisp/org.el (org-agenda-file-p): Make sure all filenames are
normalized before performing comparison.
---
 lisp/org.el | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index d702cf5..8ac4780 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -18181,8 +18181,10 @@ used by the agenda files.  If ARCHIVE is `ifmode', do this only if
   Return non-nil, if FILE is an agenda file.
 If FILE is omitted, use the file associated with the current
 buffer.
-  (member (or file (buffer-file-name))
-  (org-agenda-files t)))
+  (let ((fname (or file (buffer-file-name
+(and fname
+ (member (file-truename fname)
+ (mapcar #'file-truename (org-agenda-files t))
 
 (defun org-edit-agenda-file-list ()
   Edit the list of agenda files.
-- 
2.1.2



Re: [O] tests with travis-ci

2013-03-31 Thread Yann Hodique
On Fri, Mar 22, 2013 at 10:40 AM, Yagnesh Raghava Yakkala
h...@yagnesh.org wrote:

 On Mar 22 2013, Yann Hodique yann.hodi...@gmail.com wrote:

  If so, it might be worth waiting for me to fix it (I'm afraid it's not
  there simply because I didn't need it :)). It would be sad to limit
  yourself just because of that. Assuming ert-x.el can be backported
  easily, I'll try and work on it in the coming days.

 That would be useful.

It should now be ok, with virtualenv-emacs 0.1.5 (that grabs an
ert-x.el from marmalade).

Cheers,

Yann.



Re: [O] tests with travis-ci

2013-03-22 Thread Yann Hodique
 Yagnesh == Yagnesh Raghava Yakkala h...@yagnesh.org writes:

 [CC'ed to Yann Hodique to acknowledge him]

 Hello Bastien,

 I am attaching a patch, please have a look. (especially change in
 org-test.el)

 It is directly copied from Magit (with one minor change). It uses
 Yann's virtualenv-emacs¹ python package which creates multiple
 emacs environments.

Hi,

overall looks good to me. I'm glad to see that it might be useful for
others :)

 diff --git a/testing/org-test.el b/testing/org-test.el
 index 0c9ca58..5f8dd52 100644
 --- a/testing/org-test.el
 +++ b/testing/org-test.el
 @@ -79,7 +79,6 @@
   Parent major mode from which special major modes should inherit.
   (setq buffer-read-only t)))
  (require 'ert)
 -(require 'ert-x)
  (when (file-exists-p
  (expand-file-name jump/jump.el org-test-dir))
(require 'jump)

About that, is it just because my code doesn't install a working
ert-x.el for emacs 23 ?

If so, it might be worth waiting for me to fix it (I'm afraid it's not
there simply because I didn't need it :)). It would be sad to limit
yourself just because of that. Assuming ert-x.el can be backported
easily, I'll try and work on it in the coming days.

Cheers,

Yann.

-- 
The greatest and most important problems of life cannot be solved.
They can only be outgrown.

  -- SISTER JESSICA, private journal entry




Re: [O] tabulated-list

2013-02-26 Thread Yann Hodique
 François == François Pinard pin...@iro.umontreal.ca writes:

 Hi, Org people.
 This morning, I could not load Org because ox.el calls function
 tabulated-list, which does not seem to exist on this version of Emacs.
 So I fetched the one at https://github.com/sigma/tabulated-list.el to
 get going, but others will likely have the same problem.

Hi,

note that I uploaded this tabulated-list.el version as version 0 (since
unfortunately the builtin package doesn't have a version number...) in
marmalade. So that if org is made to depend on the tabulated-list
package *and* you have marmalade activated, M-x package-install should
handle the rest.

I guess a proper solution would have to have those packages in the
official ELPA as well, so that they can be made backward-compatible. But
all in all, packages for older Emacs versions are a mess.

Yann.

-- 
It's easier to be terrified by an enemy you admire.

  -- THUFIR HAWAT, Mentat and Security Commander to House Atreides



Re: [O] [PATCH] Fix inconsistency in drawer handling

2012-09-16 Thread Yann Hodique
 Nicolas == Nicolas Goaziou n.goaz...@gmail.com writes:

 This patch is good, but I'd rather hard-code the regexp within
 org-element: I'm slowly trying to make this library as low-level as
 possible. Do you mind changing it?

Hi,

thanks for the quick review. Of course I don't mind, but I'm just
curious to understand the purpose, as duplicating constants seems to
make room for future mistakes (even though in this case I guess we're
stuck with that regexp forever :)).

Do you mean you'd like to get rid of (require 'org) in org-element.el at
some point ? What about (eval-when-compile '(require 'org)) then ? Or
some (require 'org-const) ?

Thanks,

Yann.

-- 
How often it is that the angry man rages denial of what his inner self is 
telling him.

  -- The Collected Sayings of Muad'Dib by the Princess Irulan




[O] [PATCH] Fix inconsistency in drawer handling

2012-09-15 Thread Yann Hodique
Hi,

I've noticed that drawers are not managed similarly, depending on the
workflow. More precisely, the end-of-drawer detection is not exactly
the same for various exports, org-element, or folding. It all boils
down to variations around (re-search-forward :END:).

In particular, it's expected that property drawers for taskjuggler
export will contain an :end: key (which is arguably a bad idea by
itself), that fools some other parts of org.

This patch is an attempt at making drawers handling more predictable.

Thanks,

Yann.

Yann Hodique (1):
  Fix inconsistency in drawer handling

 lisp/org-element.el |  8 
 lisp/org.el | 18 --
 2 files changed, 16 insertions(+), 10 deletions(-)

-- 
1.7.12




[O] [PATCH] Fix inconsistency in drawer handling

2012-09-15 Thread Yann Hodique
* lisp/org.el (org-drawer-end-re): Introduce new constant.
(org-clock-drawer-start-re): Fix docstring.
(org-clock-drawer-end-re): Fix docstring.
(org-flag-drawer): Make use of `org-drawer-end-re'.
(org-end-of-meta-data-and-drawers): Make use of `org-drawer-end-re'.

* lisp/org-element.el (org-element-drawer-parser): Make use of
  `org-drawer-end-re'.
(org-element-property-drawer-parser): Make use of `org-drawer-end-re'.

Subtle differences in the definition of drawers delimiters were leading
to inconsistencies. For example, the following drawer:

  :PROPERTIES:
  :start: now
  :end:   then
  :END:

was interpreted by `org-entry-properties' as containing properties
start and end, whereas the cycling code would hide at the
first :end:, and `org-element-drawer-parser' would also consider the
black to end at the first :end:.
---
 lisp/org-element.el |  8 
 lisp/org.el | 18 --
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index bcdd336..9822045 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -529,7 +529,7 @@ Return a list whose CAR is `drawer' and CDR is a plist 
containing
 
 Assume point is at beginning of drawer.
   (let ((case-fold-search t))
-(if (not (save-excursion (re-search-forward ^[ \t]*:END: limit t)))
+(if (not (save-excursion (re-search-forward org-drawer-end-re limit t)))
;; Incomplete drawer: parse it as a paragraph.
(org-element-paragraph-parser limit)
   (let ((drawer-end-line (match-beginning 0)))
@@ -1895,7 +1895,7 @@ Assume point is at the beginning of the property drawer.
  (hidden (org-invisible-p2))
  (properties
   (let (val)
-(while (not (looking-at ^[ \t]*:END:))
+(while (not (looking-at org-property-end-re))
   (when (looking-at [ \t]*:\\([A-Za-z][-_A-Za-z0-9]*\\):)
 (push (cons (org-match-string-no-properties 1)
 (org-trim
@@ -1904,7 +1904,7 @@ Assume point is at the beginning of the property drawer.
   val))
   (forward-line))
 val))
- (prop-end (progn (re-search-forward ^[ \t]*:END: limit t)
+ (prop-end (progn (re-search-forward org-property-end-re limit t)
   (point-at-bol)))
  (pos-before-blank (progn (forward-line) (point)))
  (end (progn (skip-chars-forward  \r\t\n limit)
@@ -3395,7 +3395,7 @@ element it has to parse.
 (let ((name (match-string 1)))
  (cond
   ((not (save-excursion
-  (re-search-forward ^[ \t]*:END:[ \t]*$ nil t)))
+  (re-search-forward org-drawer-end-re nil t)))
(org-element-paragraph-parser limit))
   ((equal PROPERTIES name)
(org-element-property-drawer-parser limit))
diff --git a/lisp/org.el b/lisp/org.el
index 1c18d70..f62bde6 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6768,6 +6768,9 @@ open and agenda-wise Org files.
(while (re-search-forward org-drawer-regexp end t)
  (org-flag-drawer t))
 
+(eval-when-compile
+  (defvar org-drawer-end-re))
+
 (defun org-flag-drawer (flag)
   When FLAG is non-nil, hide the drawer we are within.
 Otherwise make it visible.
@@ -6776,7 +6779,7 @@ Otherwise make it visible.
 (when (looking-at ^[ \t]*:[a-zA-Z][a-zA-Z0-9]*:)
   (let ((b (match-end 0)))
(if (re-search-forward
-^[ \t]*:END:
+org-drawer-end-re
 (save-excursion (outline-next-heading) (point)) t)
(outline-flag-region b (point-at-eol) flag)
  (error :END: line missing at position %s b))
@@ -14308,17 +14311,20 @@ but in some other way.)
   Some properties that are used by Org-mode for various purposes.
 Being in this list makes sure that they are offered for completion.)
 
+(defconst org-drawer-end-re ^[ \t]*:END:[ \t]*$
+  Regular expression matching the last line of a drawer.)
+
 (defconst org-property-start-re ^[ \t]*:PROPERTIES:[ \t]*$
   Regular expression matching the first line of a property drawer.)
 
-(defconst org-property-end-re ^[ \t]*:END:[ \t]*$
+(defconst org-property-end-re org-drawer-end-re
   Regular expression matching the last line of a property drawer.)
 
 (defconst org-clock-drawer-start-re ^[ \t]*:CLOCK:[ \t]*$
-  Regular expression matching the first line of a property drawer.)
+  Regular expression matching the first line of a clock drawer.)
 
-(defconst org-clock-drawer-end-re ^[ \t]*:END:[ \t]*$
-  Regular expression matching the first line of a property drawer.)
+(defconst org-clock-drawer-end-re org-drawer-end-re
+  Regular expression matching the first line of a clock drawer.)
 
 (defconst org-property-drawer-re
   (concat \\( org-property-start-re \\)[^\000]*\\(
@@ -22080,7 +22086,7 @@ clocking lines, and drawers.
  ;; empty or planning line
  (forward-line 1)
;; a drawer, find the end
-   

Re: [O] Creating Gantt charts by Exporting to TaskJuggler 3.3.0

2012-09-14 Thread Yann Hodique
 Buddy == Buddy Butterfly buddy.butter...@web.de writes:

 Am 14.09.2012 17:09, schrieb:
 Hi, Seb,
 almost one month ago Yann Hodique proposed 10 patches for the taskjuggler 
 exporter,
 please see:
 
 
 http://article.gmane.org/gmane.emacs.orgmode/58851
 
 Bastien has a branch with these patches, but he'll apply them
 when he will have received the FSF papers signed.
 I hope soon :-)
 
 But I'm pretty sure you can apply them to your file.
 
 cheers,
 
 Giovanni
 

 Hi Giovanni,

 thanks for info. I will give this a try when I'll find the time.
 At the moment, because of the scrambled handling of task_ids it
 is not really usable. Let's see what he fixed in it.

Hi,

actually, those patches have been merged in master already (now that the
paperwork is in order :))

That said, I don't think it'll fix anything regarding task_id handling.
I started using TJ with versions 3.x, so I'm not sure what problem
you're talking about exactly.

At the moment I'm kinda contemplating doing a major rewrite of the TJ
exporter to use the org-export framework, which would make it easier to
introduce things like task references through org links, and so on. If
I can fix a thing or two in the process, I'd be happy to. So, if you
have specific limitations in mind, feel free to elaborate.

Cheers,

Yann.

-- 
All technology is suspect, and must be considered potentially dangerous.

  -- BUTLERIAN JIHAD, Handbook for Our Grandchildren



Re: [O] [PATCH v2 00/11] Takjuggler exporter improvements

2012-08-16 Thread Yann Hodique
 Bastien == Bastien  b...@altern.org writes:

 Thanks for this effort -- not nitpicking, but there is room left for
 small improvements.

Sure, no problem. I will do that right away. Actually the last series
was a bit messy anyway, with my old 4/10 showing up again (which brought
confusion to patchwork).

Thanks,

Yann.

-- 
There is no escape--we pay for the violence of our ancestors. 

  -- from The Collected Sayings of Muad'Dib by the Princess Irulan



[O] [PATCH v3 00/11] Taskjuggler exporter improvements

2012-08-16 Thread Yann Hodique
Hi,

here is a new version of the patch series.
Changes are:

- fixed commit messages format

Yann Hodique (11):
  org-taskjuggler.el: Make task and resource properties customizable
  org-taskjuggler.el: Properly install local variables at export time
  org-taskjuggler.el: Make use of org properties
  org-taskjuggler.el: Fix milestone definition
  org-taskjuggler.el: Introduce a global header, for early macros
  org-taskjuggler.el: Use project end date, if specified
  org-taskjuggler.el: Make project umbrella task optional
  org-taskjuggler.el: Disambiguate headline, as it's a valid attribute
  org-taskjuggler.el: Allow reports definition from within the org file
  org-taskjuggler.el: Update doc to reflect latest changes
  org-taskjuggler.el: Make taskjuggler compatible with org-publish

 doc/org.texi|  48 -
 lisp/org-publish.el |   6 ++
 lisp/org-taskjuggler.el | 180 ++--
 3 files changed, 180 insertions(+), 54 deletions(-)

-- 
1.7.11.4




[O] [PATCH v3 03/11] org-taskjuggler.el: Make use of org properties

2012-08-16 Thread Yann Hodique
* org-taskjuggler.el (org-taskjuggler-date): Introduce new function to
produce a taskjuggler-compatible date.
(org-taskjuggler-components): Make use of SCHEDULED/DEADLINE properties.

Infer start and end date from SCHEDULED/DEADLINE information.
---
 lisp/org-taskjuggler.el | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index 529cda0..93f0cc7 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -138,8 +138,6 @@
 ;;   :END:
 ;;
  * TODO
-;;   - Use SCHEDULED and DEADLINE information (not just start and end
-;; properties).
 ;;   - Look at org-file-properties, org-global-properties and
 ;; org-global-properties-fixed
 ;;   - What about property inheritance and org-property-inherit-p?
@@ -385,6 +383,10 @@ with the TaskJuggler GUI.
   (save-excursion
 (and (org-up-heading-safe) (org-entry-get (point) ORDERED
 
+(defun org-taskjuggler-date (date)
+  (let ((time (parse-time-string date)))
+(format %d-%02d-%02d (nth 5 time) (nth 4 time) (nth 3 time
+
 (defun org-taskjuggler-components ()
   Return an alist containing all the pertinent information for
 the current node such as the headline, the level, todo state
@@ -396,6 +398,12 @@ information, all the properties, etc.
  (replace-regexp-in-string
   \ \\\ (nth 4 components) t t)) ; quote double quotes in 
headlines
 (parent-ordered (org-taskjuggler-parent-is-ordered-p)))
+(let ((scheduled (assoc SCHEDULED props))
+ (deadline (assoc DEADLINE props)))
+  (when scheduled
+   (push (cons start (org-taskjuggler-date (cdr scheduled))) props))
+  (when deadline
+   (push (cons end (org-taskjuggler-date (cdr deadline))) props)))
 (push (cons level level) props)
 (push (cons headline headline) props)
 (push (cons parent-ordered parent-ordered) props)))
-- 
1.7.11.4




[O] [PATCH v3 07/11] org-taskjuggler.el: Make project umbrella task optional

2012-08-16 Thread Yann Hodique
* org-taskjuggler.el (org-export-taskjuggler-keep-project-as-task): Add
new option.
(org-export-as-taskjuggler): Optionally drop the topmost task
(project).
(org-taskjuggler-assign-task-ids): Adapt path computation by optionally
dropping the topmost component (project).

Introduce `org-export-taskjuggler-keep-project-as-task' as a flag to
toggle the behavior. Keep old behavior as default.
---
 lisp/org-taskjuggler.el | 23 ---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index 7376302..3c97e03 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -264,6 +264,14 @@ but before any resource and task declarations.
   the corresponding resource.
   :group 'org-export-taskjuggler)
 
+(defcustom org-export-taskjuggler-keep-project-as-task t
+  Whether to keep the project headline as an umbrella task for
+  all declared tasks. Setting this to nil will allow maintaining
+  completely separated task buckets, while still sharing the same
+  resources pool.
+  :group 'org-export-taskjuggler
+  :type 'boolean)
+
 ;;; Hooks
 
 (defvar org-export-taskjuggler-final-hook nil
@@ -350,7 +358,10 @@ defined in `org-export-taskjuggler-default-reports'.
 
   (org-clone-local-variables old-buffer ^org-)
   (insert org-export-taskjuggler-default-global-header)
-  (org-taskjuggler-open-project (car tasks))
+  (org-taskjuggler-open-project
+   (if org-export-taskjuggler-keep-project-as-task
+  (car tasks)
+(pop tasks)))
   (insert org-export-taskjuggler-default-global-properties)
   (insert \n)
   (dolist (resource resources)
@@ -365,7 +376,9 @@ defined in `org-export-taskjuggler-default-reports'.
  (org-taskjuggler-close-maybe level)
  (org-taskjuggler-open-task task)
  (setq org-export-taskjuggler-old-level level)))
-  (org-taskjuggler-close-maybe 1)
+  (org-taskjuggler-close-maybe
+   (if org-export-taskjuggler-keep-project-as-task
+  1 2))
   (org-taskjuggler-insert-reports)
   (save-buffer)
   (or (org-export-push-to-kill-ring TaskJuggler)
@@ -446,7 +459,11 @@ a path to the current task.
  (push unique-id (car unique-ids))
  (setcar path unique-id)))
(push (cons unique-id unique-id) task)
-   (push (cons path (mapconcat 'identity (reverse path) .)) task)
+   (push (cons path
+   (mapconcat 'identity
+  (if org-export-taskjuggler-keep-project-as-task
+  (reverse path)
+(cdr (reverse path))) .)) task)
(setq previous-level level)
(setq resolved-tasks (append resolved-tasks (list task)))
 
-- 
1.7.11.4




[O] [PATCH v3 04/11] org-taskjuggler.el: Fix milestone definition

2012-08-16 Thread Yann Hodique
* org-taskjuggler.el (org-taskjuggler-open-task): Task with end-only is
also a milestone (deadline), task with length is not.
---
 lisp/org-taskjuggler.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index 93f0cc7..a18cdf8 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -689,8 +689,10 @@ org-mode priority string.
 (milestone (or (cdr (assoc milestone task))
(and (assoc leaf-node task)
 (not (or effort
+ (cdr (assoc length task))
  (cdr (assoc duration task))
- (cdr (assoc end task))
+ (and (cdr (assoc start task))
+  (cdr (assoc end task)))
  (cdr (assoc period task)))
 (attributes org-export-taskjuggler-valid-task-attributes))
 (insert
-- 
1.7.11.4




[O] [PATCH v3 01/11] org-taskjuggler.el: Make task and resource properties customizable

2012-08-16 Thread Yann Hodique
* org-taskjuggler.el (org-export-taskjuggler-valid-task-attributes): Add
new option.
(org-export-taskjuggler-valid-resource-attributes): Add new custom
option.
---
 lisp/org-taskjuggler.el | 26 --
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index aa645d2..7d9d203 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -240,6 +240,24 @@ but before any resource and task declarations.
   :version 24.1
   :type '(string :tag Preamble))
 
+(defcustom org-export-taskjuggler-valid-task-attributes
+  '(account start note duration endbuffer endcredit end
+   flags journalentry length limits maxend maxstart minend
+   minstart period reference responsible scheduling
+   startbuffer startcredit statusnote)
+  Valid attributes for Taskjuggler tasks. If one of these
+  appears as a property for a headline, it will be exported with
+  the corresponding task.
+  :group 'org-export-taskjuggler)
+
+(defcustom org-export-taskjuggler-valid-resource-attributes
+  '(limits vacation shift booking efficiency journalentry rate
+  workinghours flags)
+  Valid attributes for Taskjuggler resources. If one of these
+  appears as a property for a headline, it will be exported with
+  the corresponding resource.
+  :group 'org-export-taskjuggler)
+
 ;;; Hooks
 
 (defvar org-export-taskjuggler-final-hook nil
@@ -614,7 +632,7 @@ is defined it will calculate a unique id for the resource 
using
 (cdr (assoc ID resource))
 (cdr (assoc unique-id resource)
(headline (cdr (assoc headline resource)))
-   (attributes '(limits vacation shift booking efficiency journalentry 
rate)))
+   (attributes org-export-taskjuggler-valid-resource-attributes))
 (insert
  (concat
   resource  id  \ headline \ {\n 
@@ -655,11 +673,7 @@ org-mode priority string.
  (cdr (assoc duration task))
  (cdr (assoc end task))
  (cdr (assoc period task)))
-(attributes
- '(account start note duration endbuffer endcredit end
-   flags journalentry length maxend maxstart minend
-   minstart period reference responsible scheduling
-   startbuffer startcredit statusnote)))
+(attributes org-export-taskjuggler-valid-task-attributes))
 (insert
  (concat
   task  unique-id  \ headline \ {\n
-- 
1.7.11.4




[O] [PATCH v3 08/11] org-taskjuggler.el: Disambiguate headline, as it's a valid attribute

2012-08-16 Thread Yann Hodique
---
 lisp/org-taskjuggler.el | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index 3c97e03..33b111d 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -329,7 +329,7 @@ defined in `org-export-taskjuggler-default-reports'.
 (unless resources
   (setq resources
`(((resource_id . ,(user-login-name))
-  (headline . ,user-full-name)
+  (HEADLINE . ,user-full-name)
   (level . 1)
 ;; add a default allocation to the first task if none was given
 (unless (assoc allocate (car tasks))
@@ -427,7 +427,7 @@ information, all the properties, etc.
   (when deadline
(push (cons end (org-taskjuggler-date (cdr deadline))) props)))
 (push (cons level level) props)
-(push (cons headline headline) props)
+(push (cons HEADLINE headline) props)
 (push (cons parent-ordered parent-ordered) props)))
 
 (defun org-taskjuggler-assign-task-ids (tasks)
@@ -601,7 +601,7 @@ The id is derived from the headline and made unique against
 UNIQUE-IDS. If the (downcased) first token of the headline is not
 unique try to add more (downcased) tokens of the headline or
 finally add more underscore characters (\_\).
-  (let* ((headline (cdr (assoc headline item)))
+  (let* ((headline (cdr (assoc HEADLINE item)))
 (parts (split-string headline))
 (id (org-taskjuggler-clean-id (downcase (pop parts)
; try to add more parts of the headline 
to make it unique
@@ -627,7 +627,7 @@ attributes from the PROJECT alist are inserted.  If no end 
date is
 specified it is calculated
 `org-export-taskjuggler-default-project-duration' days from now.
   (let* ((unique-id (cdr (assoc unique-id project)))
-(headline (cdr (assoc headline project)))
+(headline (cdr (assoc HEADLINE project)))
 (version (cdr (assoc version project)))
 (start (cdr (assoc start project)))
 (end (cdr (assoc end project
@@ -678,7 +678,7 @@ is defined it will calculate a unique id for the resource 
using
 (or (cdr (assoc resource_id resource))
 (cdr (assoc ID resource))
 (cdr (assoc unique-id resource)
-   (headline (cdr (assoc headline resource)))
+   (headline (cdr (assoc HEADLINE resource)))
(attributes org-export-taskjuggler-valid-resource-attributes))
 (insert
  (concat
@@ -703,7 +703,7 @@ org-mode priority string.
 
 (defun org-taskjuggler-open-task (task)
   (let* ((unique-id (cdr (assoc unique-id task)))
-(headline (cdr (assoc headline task)))
+(headline (cdr (assoc HEADLINE task)))
 (effort (org-taskjuggler-clean-effort (cdr (assoc org-effort-property 
task
 (depends (cdr (assoc depends task)))
 (allocate (cdr (assoc allocate task)))
-- 
1.7.11.4




[O] [PATCH v3 06/11] org-taskjuggler.el: Use project end date, if specified

2012-08-16 Thread Yann Hodique
* org-taskjuggler.el (org-taskjuggler-open-project): Use START - END as
an alternative to START +Xd.
---
 lisp/org-taskjuggler.el | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index c997da7..7376302 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -615,9 +615,11 @@ specified it is calculated
 (start (cdr (assoc start project)))
 (end (cdr (assoc end project
 (insert
- (format project %s \%s\ \%s\ %s +%sd {\n }\n
+ (format project %s \%s\ \%s\ %s %s {\n }\n
 unique-id headline version start
-org-export-taskjuggler-default-project-duration
+ (or (and end (format - %s end))
+ (format +%sd
+ org-export-taskjuggler-default-project-duration))
 
 (defun org-taskjuggler-filter-and-join (items)
   Filter all nil elements from ITEMS and join the remaining ones
-- 
1.7.11.4




[O] [PATCH v3 09/11] org-taskjuggler.el: Allow reports definition from within the org file

2012-08-16 Thread Yann Hodique
* org-taskjuggler.el (org-export-taskjuggler-report-tag): Add
new option.
(org-export-taskjuggler-valid-report-attributes): Add new option.
(org-export-as-taskjuggler): Compute reports.
(org-taskjuggler-open-report): Generate report from org item.
(org-taskjuggler-insert-reports): Insert default reports only if no
explicit one is defined.
---
 lisp/org-taskjuggler.el | 42 +-
 1 file changed, 37 insertions(+), 5 deletions(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index 33b111d..49c24ff 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -181,6 +181,13 @@ resources for the project.
   :version 24.1
   :type 'string)
 
+(defcustom org-export-taskjuggler-report-tag taskjuggler_report
+  Tag, property or todo used to find the tree containing all the
+reports for the project.
+  :group 'org-export-taskjuggler
+  :version 24.1
+  :type 'string)
+
 (defcustom org-export-taskjuggler-target-version 2.4
   Which version of TaskJuggler the exporter is targeting.
   :group 'org-export-taskjuggler
@@ -264,6 +271,14 @@ but before any resource and task declarations.
   the corresponding resource.
   :group 'org-export-taskjuggler)
 
+(defcustom org-export-taskjuggler-valid-report-attributes
+  '(headline columns definitions timeformat hideresource hidetask
+loadunit sorttasks formats period)
+  Valid attributes for Taskjuggler reports. If one of these
+  appears as a property for a headline, it will be exported with
+  the corresponding report.
+  :group 'org-export-taskjuggler)
+
 (defcustom org-export-taskjuggler-keep-project-as-task t
   Whether to keep the project headline as an umbrella task for
   all declared tasks. Setting this to nil will allow maintaining
@@ -314,6 +329,10 @@ defined in `org-export-taskjuggler-default-reports'.
   (org-map-entries
'org-taskjuggler-components
org-export-taskjuggler-resource-tag nil 'archive 'comment)))
+(reports
+ (org-map-entries
+  'org-taskjuggler-components
+  org-export-taskjuggler-report-tag nil 'archive 'comment))
 (filename (expand-file-name
(concat
 (file-name-sans-extension
@@ -379,7 +398,7 @@ defined in `org-export-taskjuggler-default-reports'.
   (org-taskjuggler-close-maybe
(if org-export-taskjuggler-keep-project-as-task
   1 2))
-  (org-taskjuggler-insert-reports)
+  (org-taskjuggler-insert-reports reports)
   (save-buffer)
   (or (org-export-push-to-kill-ring TaskJuggler)
  (message Exporting... done))
@@ -741,6 +760,16 @@ org-mode priority string.
   (org-taskjuggler-get-attributes task attributes)
   \n
 
+(defun org-taskjuggler-open-report (report)
+  (let* ((kind (or (cdr (assoc report-kind report)) taskreport))
+(headline (cdr (assoc HEADLINE report)))
+(attributes org-export-taskjuggler-valid-report-attributes))
+(insert
+ (concat
+  kind  \ headline \ {\n
+  (org-taskjuggler-get-attributes report attributes)
+  \n}\n
+
 (defun org-taskjuggler-close-maybe (level)
   (while ( org-export-taskjuggler-old-level level)
 (insert }\n)
@@ -748,10 +777,13 @@ org-mode priority string.
   (when (= org-export-taskjuggler-old-level level)
 (insert }\n)))
 
-(defun org-taskjuggler-insert-reports ()
-  (let (report)
-(dolist (report org-export-taskjuggler-default-reports)
-  (insert report \n
+(defun org-taskjuggler-insert-reports (reports)
+  (if reports
+  (dolist (report (cdr reports))
+   (org-taskjuggler-open-report report))
+(let (report)
+  (dolist (report org-export-taskjuggler-default-reports)
+   (insert report \n)
 
 (provide 'org-taskjuggler)
 
-- 
1.7.11.4




[O] [PATCH v3 11/11] org-taskjuggler.el: Make taskjuggler compatible with org-publish

2012-08-16 Thread Yann Hodique
* lisp/org-publish.el (org-publish-org-to-taskjuggler): New function to
publish taskjuggler projects.
* lisp/org-taskjuggler.el (org-export-as-taskjuggler): Adapt signature
to reflect standard interface, in particular allow export to buffer.
---
 lisp/org-publish.el |  6 ++
 lisp/org-taskjuggler.el | 33 +++--
 2 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/lisp/org-publish.el b/lisp/org-publish.el
index ed2db3a..e78e2d4 100644
--- a/lisp/org-publish.el
+++ b/lisp/org-publish.el
@@ -649,6 +649,12 @@ See `org-publish-org-to' to the list of arguments.
   (org-publish-with-aux-preprocess-maybe
(org-publish-org-to utf8 plist filename pub-dir)))
 
+(defun org-publish-org-to-taskjuggler (plist filename pub-dir)
+  Publish an org file to TaskJuggler.
+See `org-publish-org-to' to the list of arguments.
+  (org-publish-with-aux-preprocess-maybe
+   (org-publish-org-to taskjuggler plist filename pub-dir)))
+
 (defun org-publish-attachment (plist filename pub-dir)
   Publish a file with no transformation of any kind.
 See `org-publish-org-to' to the list of arguments.
diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index 49c24ff..1733fe8 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -298,7 +298,8 @@ but before any resource and task declarations.
 (defvar org-export-taskjuggler-old-level)
 
 ;;;###autoload
-(defun org-export-as-taskjuggler ()
+(defun org-export-as-taskjuggler (optional arg hidden ext-plist
+   to-buffer body-only pub-dir)
   Export parts of the current buffer as a TaskJuggler file.
 The exporter looks for a tree with tag, property or todo that
 matches `org-export-taskjuggler-project-tag' and takes this as
@@ -310,11 +311,12 @@ resources for the project.  If no resources are 
specified, a
 default resource is created and allocated to the project.  Also
 the taskjuggler project will be created with default reports as
 defined in `org-export-taskjuggler-default-reports'.
-  (interactive)
+  (interactive P)
 
   (message Exporting...)
   (setq-default org-done-keywords org-done-keywords)
   (let* ((opt-plist (org-combine-plists (org-default-export-plist)
+   ext-plist
 (org-infile-export-plist)))
 (org-export-opt-plist opt-plist)
  (tasks
@@ -333,12 +335,20 @@ defined in `org-export-taskjuggler-default-reports'.
  (org-map-entries
   'org-taskjuggler-components
   org-export-taskjuggler-report-tag nil 'archive 'comment))
-(filename (expand-file-name
-   (concat
-(file-name-sans-extension
- (file-name-nondirectory buffer-file-name))
-org-export-taskjuggler-extension)))
-(buffer (find-file-noselect filename))
+(filename (if to-buffer
+  nil
+(concat (file-name-as-directory
+ (or pub-dir
+ (org-export-directory :tj opt-plist)))
+(file-name-sans-extension
+ (file-name-nondirectory buffer-file-name))
+org-export-taskjuggler-extension)))
+(buffer (if to-buffer
+(cond
+ ((eq to-buffer 'string)
+  (get-buffer-create *Org Taskjuggler Export*))
+ (t (get-buffer-create to-buffer)))
+  (find-file-noselect filename)))
 (old-buffer (current-buffer))
 (org-export-taskjuggler-old-level 0)
 task resource)
@@ -399,10 +409,13 @@ defined in `org-export-taskjuggler-default-reports'.
(if org-export-taskjuggler-keep-project-as-task
   1 2))
   (org-taskjuggler-insert-reports reports)
-  (save-buffer)
+  (or to-buffer (save-buffer))
   (or (org-export-push-to-kill-ring TaskJuggler)
  (message Exporting... done))
-  (current-buffer
+  (if (eq to-buffer 'string)
+ (prog1 (buffer-substring (point-min) (point-max))
+   (kill-buffer (current-buffer)))
+   (current-buffer)
 
 ;;;###autoload
 (defun org-export-as-taskjuggler-and-open ()
-- 
1.7.11.4




[O] [PATCH v3 05/11] org-taskjuggler.el: Introduce a global header, for early macros

2012-08-16 Thread Yann Hodique
* org-taskjuggler.el (org-export-taskjuggler-default-global-header): Add
new option.
(org-export-as-taskjuggler): Insert global header before anything else.
---
 lisp/org-taskjuggler.el | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index a18cdf8..c997da7 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -221,6 +221,14 @@ with `org-export-taskjuggler-project-tag'
   :version 24.1
   :type '(repeat (string :tag Report)))
 
+(defcustom org-export-taskjuggler-default-global-header
+  
+  Default global header for the project. This goes before
+project declaration, and might be useful for early macros
+  :group 'org-export-taskjuggler
+  :version 24.1
+  :type '(string :tag Preamble))
+
 (defcustom org-export-taskjuggler-default-global-properties
   shift s40 \Part time shift\ {
   workinghours wed, thu, fri off
@@ -332,11 +340,6 @@ defined in `org-export-taskjuggler-default-reports'.
(setcar tasks (push (cons version version) task
 (with-current-buffer buffer
   (erase-buffer)
-  (org-clone-local-variables old-buffer ^org-)
-  (org-taskjuggler-open-project (car tasks))
-  (insert org-export-taskjuggler-default-global-properties)
-  (insert \n)
-  (dolist (resource resources)
   (org-install-letbind)
   ;; create local variables for all options, to make sure all called
   ;; functions get the correct information
@@ -345,6 +348,12 @@ defined in `org-export-taskjuggler-default-reports'.
(plist-get opt-plist (car x
 org-export-plist-vars)
 
+  (org-clone-local-variables old-buffer ^org-)
+  (insert org-export-taskjuggler-default-global-header)
+  (org-taskjuggler-open-project (car tasks))
+  (insert org-export-taskjuggler-default-global-properties)
+  (insert \n)
+  (dolist (resource resources)
(let ((level (cdr (assoc level resource
  (org-taskjuggler-close-maybe level)
  (org-taskjuggler-open-resource resource)
-- 
1.7.11.4




[O] [PATCH v3 02/11] org-taskjuggler.el: Properly install local variables at export time

2012-08-16 Thread Yann Hodique
* org-taskjuggler.el (org-export-as-taskjuggler): Compute opt-plist, use
`org-install-letbind'.
---
 lisp/org-taskjuggler.el | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index 7d9d203..529cda0 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -285,7 +285,10 @@ defined in `org-export-taskjuggler-default-reports'.
 
   (message Exporting...)
   (setq-default org-done-keywords org-done-keywords)
-  (let* ((tasks
+  (let* ((opt-plist (org-combine-plists (org-default-export-plist)
+(org-infile-export-plist)))
+(org-export-opt-plist opt-plist)
+ (tasks
  (org-taskjuggler-resolve-dependencies
   (org-taskjuggler-assign-task-ids
(org-taskjuggler-compute-task-leafiness
@@ -336,6 +339,14 @@ defined in `org-export-taskjuggler-default-reports'.
   (insert org-export-taskjuggler-default-global-properties)
   (insert \n)
   (dolist (resource resources)
+  (org-install-letbind)
+  ;; create local variables for all options, to make sure all called
+  ;; functions get the correct information
+  (mapc (lambda (x)
+  (set (make-local-variable (nth 2 x))
+   (plist-get opt-plist (car x
+org-export-plist-vars)
+
(let ((level (cdr (assoc level resource
  (org-taskjuggler-close-maybe level)
  (org-taskjuggler-open-resource resource)
-- 
1.7.11.4




[O] [PATCH v3 10/11] org-taskjuggler.el: Update doc to reflect latest changes

2012-08-16 Thread Yann Hodique
---
 doc/org.texi | 48 ++--
 1 file changed, 30 insertions(+), 18 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index 3fdb4ac..0f8b0d9 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -11898,9 +11898,9 @@ nodes of a document or strictly follow the order of the 
nodes in the
 document.
 
 Instead the TaskJuggler exporter looks for a tree that defines the tasks and
-a optionally tree that defines the resources for this project.  It then
-creates a TaskJuggler file based on these trees and the attributes defined in
-all the nodes.
+optionally trees that define the resources and reports for this project.
+It then creates a TaskJuggler file based on these trees and the attributes
+defined in all the nodes.
 
 @subsection TaskJuggler export commands
 
@@ -11909,7 +11909,8 @@ all the nodes.
 Export as a TaskJuggler file.
 
 @orgcmd{C-c C-e J,org-export-as-taskjuggler-and-open}
-Export as a TaskJuggler file and then open the file with TaskJugglerUI.
+Export as a TaskJuggler file and then open the file with TaskJugglerUI (only
+for TaskJugglerUI 2.x).
 @end table
 
 @subsection Tasks
@@ -11947,15 +11948,17 @@ time.
 
 @subsection Export of properties
 
-The exporter also takes TODO state information into consideration, i.e.@: if a
-task is marked as done it will have the corresponding attribute in
-TaskJuggler (@samp{complete 100}).  Also it will export any property on a task
-resource or resource node which is known to TaskJuggler, such as
-@samp{limits}, @samp{vacation}, @samp{shift}, @samp{booking},
-@samp{efficiency}, @samp{journalentry}, @samp{rate} for resources or
-@samp{account}, @samp{start}, @samp{note}, @samp{duration}, @samp{end},
-@samp{journalentry}, @samp{milestone}, @samp{reference}, @samp{responsible},
-@samp{scheduling}, etc for tasks.
+The exporter also takes TODO state information into consideration, i.e.@: if
+a task is marked as done it will have the corresponding attribute in
+TaskJuggler (@samp{complete 100}).  Scheduling information is also taken into
+account to set start/end dates for tasks.
+
+The exporter will also export any property on a task resource or resource
+node which is known to TaskJuggler, such as @samp{limits}, @samp{vacation},
+@samp{shift}, @samp{booking}, @samp{efficiency}, @samp{journalentry},
+@samp{rate} for resources or @samp{account}, @samp{start}, @samp{note},
+@samp{duration}, @samp{end}, @samp{journalentry}, @samp{milestone},
+@samp{reference}, @samp{responsible}, @samp{scheduling}, etc for tasks.
 
 @subsection Dependencies
 
@@ -12001,11 +12004,20 @@ examples should illustrate this:
 @vindex org-export-taskjuggler-default-reports
 TaskJuggler can produce many kinds of reports (e.g.@: gantt chart, resource
 allocation, etc).  The user defines what kind of reports should be generated
-for a project in the TaskJuggler file.  The exporter will automatically insert
-some default reports in the file.  These defaults are defined in
-@code{org-export-taskjuggler-default-reports}.  They can be modified using
-customize along with a number of other options.  For a more complete list, see
-@kbd{M-x customize-group @key{RET} org-export-taskjuggler @key{RET}}.
+for a project in the TaskJuggler file.  By default, the exporter will
+automatically insert some pre-set reports in the file.  These defaults are
+defined in @code{org-export-taskjuggler-default-reports}.  They can be
+modified using customize along with a number of other options.  For a more
+complete list, see @kbd{M-x customize-group @key{RET} org-export-taskjuggler
+@key{RET}}.
+
+Alternately, the user can tag a tree with
+@code{org-export-taskjuggler-report-tag}, and define reports in sub-nodes,
+similarly to what is done with tasks or resources.  The properties used for
+report generation are defined in
+@code{org-export-taskjuggler-valid-report-attributes}. In addition, a special
+property named @samp{report-kind} is used to define the kind of report one
+wants to generate (by default, a @samp{taskreport}).
 
 For more information and examples see the Org-taskjuggler tutorial at
 @uref{http://orgmode.org/worg/org-tutorials/org-taskjuggler.html}.
-- 
1.7.11.4




[O] [PATCH v2 00/11] Takjuggler exporter improvements

2012-08-15 Thread Yann Hodique
Hi,

here is a new version of the patch series.
Changes are:

- fixed commit messages format

- added a few missing attributes in
  `org-export-taskjuggler-valid-resource-attributes' (1/11) and
  `org-export-taskjuggler-valid-report-attributes' (9/11)

- added another milestone-related fix: attribute length prevents
  milestone creation (same as duration). Fix merged into 4/11

- added another patch (11/11) to make org-publish taskjuggler-capable.
  Feel free to reject this one if it's deemed undesirable.

Thanks,
Yann.

Yann Hodique (11):
  org-taskjuggler: make task and resource properties customizable
  org-taskjuggler: properly install local variables at export time
  org-taskjuggler: make use of org properties
  org-taskjuggler: fix milestone definition
  org-taskjuggler: introduce a global header, for early macros
  org-taskjuggler: use project end date, if specified
  org-taskjuggler: make project umbrella task optional
  org-taskjuggler: disambiguate headline, as it's also a valid
property
  org-taskjuggler: allow reports definition from within the org file
  org-taskjuggler: update doc to reflect latest changes
  org-taskjuggler: make taskjuggler compatible with org-publish

 doc/org.texi|  48 -
 lisp/org-publish.el |   6 ++
 lisp/org-taskjuggler.el | 180 ++--
 3 files changed, 180 insertions(+), 54 deletions(-)

-- 
1.7.11.4




[O] [PATCH v2 01/11] org-taskjuggler: make task and resource properties customizable

2012-08-15 Thread Yann Hodique
* org-taskjuggler.el (org-export-taskjuggler-valid-task-attributes): new custom 
variable
(org-export-taskjuggler-valid-resource-attributes): new custom variable
---
 lisp/org-taskjuggler.el | 26 --
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index aa645d2..7d9d203 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -240,6 +240,24 @@ but before any resource and task declarations.
   :version 24.1
   :type '(string :tag Preamble))
 
+(defcustom org-export-taskjuggler-valid-task-attributes
+  '(account start note duration endbuffer endcredit end
+   flags journalentry length limits maxend maxstart minend
+   minstart period reference responsible scheduling
+   startbuffer startcredit statusnote)
+  Valid attributes for Taskjuggler tasks. If one of these
+  appears as a property for a headline, it will be exported with
+  the corresponding task.
+  :group 'org-export-taskjuggler)
+
+(defcustom org-export-taskjuggler-valid-resource-attributes
+  '(limits vacation shift booking efficiency journalentry rate
+  workinghours flags)
+  Valid attributes for Taskjuggler resources. If one of these
+  appears as a property for a headline, it will be exported with
+  the corresponding resource.
+  :group 'org-export-taskjuggler)
+
 ;;; Hooks
 
 (defvar org-export-taskjuggler-final-hook nil
@@ -614,7 +632,7 @@ is defined it will calculate a unique id for the resource 
using
 (cdr (assoc ID resource))
 (cdr (assoc unique-id resource)
(headline (cdr (assoc headline resource)))
-   (attributes '(limits vacation shift booking efficiency journalentry 
rate)))
+   (attributes org-export-taskjuggler-valid-resource-attributes))
 (insert
  (concat
   resource  id  \ headline \ {\n 
@@ -655,11 +673,7 @@ org-mode priority string.
  (cdr (assoc duration task))
  (cdr (assoc end task))
  (cdr (assoc period task)))
-(attributes
- '(account start note duration endbuffer endcredit end
-   flags journalentry length maxend maxstart minend
-   minstart period reference responsible scheduling
-   startbuffer startcredit statusnote)))
+(attributes org-export-taskjuggler-valid-task-attributes))
 (insert
  (concat
   task  unique-id  \ headline \ {\n
-- 
1.7.11.4




[O] [PATCH v2 03/11] org-taskjuggler: make use of org properties

2012-08-15 Thread Yann Hodique
* org-taskjuggler.el (org-taskjuggler-date): new function, produce a
taskjuggler-compatible date
(org-taskjuggler-components): make use of SCHEDULED/DEADLINE properties

infer start and end date from SCHEDULED/DEADLINE information
---
 lisp/org-taskjuggler.el | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index 529cda0..93f0cc7 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -138,8 +138,6 @@
 ;;   :END:
 ;;
  * TODO
-;;   - Use SCHEDULED and DEADLINE information (not just start and end
-;; properties).
 ;;   - Look at org-file-properties, org-global-properties and
 ;; org-global-properties-fixed
 ;;   - What about property inheritance and org-property-inherit-p?
@@ -385,6 +383,10 @@ with the TaskJuggler GUI.
   (save-excursion
 (and (org-up-heading-safe) (org-entry-get (point) ORDERED
 
+(defun org-taskjuggler-date (date)
+  (let ((time (parse-time-string date)))
+(format %d-%02d-%02d (nth 5 time) (nth 4 time) (nth 3 time
+
 (defun org-taskjuggler-components ()
   Return an alist containing all the pertinent information for
 the current node such as the headline, the level, todo state
@@ -396,6 +398,12 @@ information, all the properties, etc.
  (replace-regexp-in-string
   \ \\\ (nth 4 components) t t)) ; quote double quotes in 
headlines
 (parent-ordered (org-taskjuggler-parent-is-ordered-p)))
+(let ((scheduled (assoc SCHEDULED props))
+ (deadline (assoc DEADLINE props)))
+  (when scheduled
+   (push (cons start (org-taskjuggler-date (cdr scheduled))) props))
+  (when deadline
+   (push (cons end (org-taskjuggler-date (cdr deadline))) props)))
 (push (cons level level) props)
 (push (cons headline headline) props)
 (push (cons parent-ordered parent-ordered) props)))
-- 
1.7.11.4




[O] [PATCH v2 10/11] org-taskjuggler: update doc to reflect latest changes

2012-08-15 Thread Yann Hodique
---
 doc/org.texi | 48 ++--
 1 file changed, 30 insertions(+), 18 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index 3fdb4ac..0f8b0d9 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -11898,9 +11898,9 @@ nodes of a document or strictly follow the order of the 
nodes in the
 document.
 
 Instead the TaskJuggler exporter looks for a tree that defines the tasks and
-a optionally tree that defines the resources for this project.  It then
-creates a TaskJuggler file based on these trees and the attributes defined in
-all the nodes.
+optionally trees that define the resources and reports for this project.
+It then creates a TaskJuggler file based on these trees and the attributes
+defined in all the nodes.
 
 @subsection TaskJuggler export commands
 
@@ -11909,7 +11909,8 @@ all the nodes.
 Export as a TaskJuggler file.
 
 @orgcmd{C-c C-e J,org-export-as-taskjuggler-and-open}
-Export as a TaskJuggler file and then open the file with TaskJugglerUI.
+Export as a TaskJuggler file and then open the file with TaskJugglerUI (only
+for TaskJugglerUI 2.x).
 @end table
 
 @subsection Tasks
@@ -11947,15 +11948,17 @@ time.
 
 @subsection Export of properties
 
-The exporter also takes TODO state information into consideration, i.e.@: if a
-task is marked as done it will have the corresponding attribute in
-TaskJuggler (@samp{complete 100}).  Also it will export any property on a task
-resource or resource node which is known to TaskJuggler, such as
-@samp{limits}, @samp{vacation}, @samp{shift}, @samp{booking},
-@samp{efficiency}, @samp{journalentry}, @samp{rate} for resources or
-@samp{account}, @samp{start}, @samp{note}, @samp{duration}, @samp{end},
-@samp{journalentry}, @samp{milestone}, @samp{reference}, @samp{responsible},
-@samp{scheduling}, etc for tasks.
+The exporter also takes TODO state information into consideration, i.e.@: if
+a task is marked as done it will have the corresponding attribute in
+TaskJuggler (@samp{complete 100}).  Scheduling information is also taken into
+account to set start/end dates for tasks.
+
+The exporter will also export any property on a task resource or resource
+node which is known to TaskJuggler, such as @samp{limits}, @samp{vacation},
+@samp{shift}, @samp{booking}, @samp{efficiency}, @samp{journalentry},
+@samp{rate} for resources or @samp{account}, @samp{start}, @samp{note},
+@samp{duration}, @samp{end}, @samp{journalentry}, @samp{milestone},
+@samp{reference}, @samp{responsible}, @samp{scheduling}, etc for tasks.
 
 @subsection Dependencies
 
@@ -12001,11 +12004,20 @@ examples should illustrate this:
 @vindex org-export-taskjuggler-default-reports
 TaskJuggler can produce many kinds of reports (e.g.@: gantt chart, resource
 allocation, etc).  The user defines what kind of reports should be generated
-for a project in the TaskJuggler file.  The exporter will automatically insert
-some default reports in the file.  These defaults are defined in
-@code{org-export-taskjuggler-default-reports}.  They can be modified using
-customize along with a number of other options.  For a more complete list, see
-@kbd{M-x customize-group @key{RET} org-export-taskjuggler @key{RET}}.
+for a project in the TaskJuggler file.  By default, the exporter will
+automatically insert some pre-set reports in the file.  These defaults are
+defined in @code{org-export-taskjuggler-default-reports}.  They can be
+modified using customize along with a number of other options.  For a more
+complete list, see @kbd{M-x customize-group @key{RET} org-export-taskjuggler
+@key{RET}}.
+
+Alternately, the user can tag a tree with
+@code{org-export-taskjuggler-report-tag}, and define reports in sub-nodes,
+similarly to what is done with tasks or resources.  The properties used for
+report generation are defined in
+@code{org-export-taskjuggler-valid-report-attributes}. In addition, a special
+property named @samp{report-kind} is used to define the kind of report one
+wants to generate (by default, a @samp{taskreport}).
 
 For more information and examples see the Org-taskjuggler tutorial at
 @uref{http://orgmode.org/worg/org-tutorials/org-taskjuggler.html}.
-- 
1.7.11.4




[O] [PATCH v2 06/11] org-taskjuggler: use project end date, if specified

2012-08-15 Thread Yann Hodique
* org-taskjuggler.el (org-taskjuggler-open-project): use START - END as an
alternative to START +Xd
---
 lisp/org-taskjuggler.el | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index c997da7..7376302 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -615,9 +615,11 @@ specified it is calculated
 (start (cdr (assoc start project)))
 (end (cdr (assoc end project
 (insert
- (format project %s \%s\ \%s\ %s +%sd {\n }\n
+ (format project %s \%s\ \%s\ %s %s {\n }\n
 unique-id headline version start
-org-export-taskjuggler-default-project-duration
+ (or (and end (format - %s end))
+ (format +%sd
+ org-export-taskjuggler-default-project-duration))
 
 (defun org-taskjuggler-filter-and-join (items)
   Filter all nil elements from ITEMS and join the remaining ones
-- 
1.7.11.4




[O] [PATCH v2 05/11] org-taskjuggler: introduce a global header, for early macros

2012-08-15 Thread Yann Hodique
* org-taskjuggler.el (org-export-taskjuggler-default-global-header): new
custom variable
(org-export-as-taskjuggler): insert global header before anything else
---
 lisp/org-taskjuggler.el | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index a18cdf8..c997da7 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -221,6 +221,14 @@ with `org-export-taskjuggler-project-tag'
   :version 24.1
   :type '(repeat (string :tag Report)))
 
+(defcustom org-export-taskjuggler-default-global-header
+  
+  Default global header for the project. This goes before
+project declaration, and might be useful for early macros
+  :group 'org-export-taskjuggler
+  :version 24.1
+  :type '(string :tag Preamble))
+
 (defcustom org-export-taskjuggler-default-global-properties
   shift s40 \Part time shift\ {
   workinghours wed, thu, fri off
@@ -332,11 +340,6 @@ defined in `org-export-taskjuggler-default-reports'.
(setcar tasks (push (cons version version) task
 (with-current-buffer buffer
   (erase-buffer)
-  (org-clone-local-variables old-buffer ^org-)
-  (org-taskjuggler-open-project (car tasks))
-  (insert org-export-taskjuggler-default-global-properties)
-  (insert \n)
-  (dolist (resource resources)
   (org-install-letbind)
   ;; create local variables for all options, to make sure all called
   ;; functions get the correct information
@@ -345,6 +348,12 @@ defined in `org-export-taskjuggler-default-reports'.
(plist-get opt-plist (car x
 org-export-plist-vars)
 
+  (org-clone-local-variables old-buffer ^org-)
+  (insert org-export-taskjuggler-default-global-header)
+  (org-taskjuggler-open-project (car tasks))
+  (insert org-export-taskjuggler-default-global-properties)
+  (insert \n)
+  (dolist (resource resources)
(let ((level (cdr (assoc level resource
  (org-taskjuggler-close-maybe level)
  (org-taskjuggler-open-resource resource)
-- 
1.7.11.4




[O] [PATCH v2 02/11] org-taskjuggler: properly install local variables at export time

2012-08-15 Thread Yann Hodique
* org-taskjuggler.el (org-export-as-taskjuggler): compute opt-plist, use
`org-install-letbind'
---
 lisp/org-taskjuggler.el | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index 7d9d203..529cda0 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -285,7 +285,10 @@ defined in `org-export-taskjuggler-default-reports'.
 
   (message Exporting...)
   (setq-default org-done-keywords org-done-keywords)
-  (let* ((tasks
+  (let* ((opt-plist (org-combine-plists (org-default-export-plist)
+(org-infile-export-plist)))
+(org-export-opt-plist opt-plist)
+ (tasks
  (org-taskjuggler-resolve-dependencies
   (org-taskjuggler-assign-task-ids
(org-taskjuggler-compute-task-leafiness
@@ -336,6 +339,14 @@ defined in `org-export-taskjuggler-default-reports'.
   (insert org-export-taskjuggler-default-global-properties)
   (insert \n)
   (dolist (resource resources)
+  (org-install-letbind)
+  ;; create local variables for all options, to make sure all called
+  ;; functions get the correct information
+  (mapc (lambda (x)
+  (set (make-local-variable (nth 2 x))
+   (plist-get opt-plist (car x
+org-export-plist-vars)
+
(let ((level (cdr (assoc level resource
  (org-taskjuggler-close-maybe level)
  (org-taskjuggler-open-resource resource)
-- 
1.7.11.4




[O] [PATCH v2 11/11] org-taskjuggler: make taskjuggler compatible with org-publish

2012-08-15 Thread Yann Hodique
* lisp/org-publish.el (org-publish-org-to-taskjuggler): new function to publish
taskjuggler projects

* lisp/org-taskjuggler.el (org-export-as-taskjuggler): adapt signature to
reflect standard interface, in particular allow export to buffer
---
 lisp/org-publish.el |  6 ++
 lisp/org-taskjuggler.el | 33 +++--
 2 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/lisp/org-publish.el b/lisp/org-publish.el
index ed2db3a..e78e2d4 100644
--- a/lisp/org-publish.el
+++ b/lisp/org-publish.el
@@ -649,6 +649,12 @@ See `org-publish-org-to' to the list of arguments.
   (org-publish-with-aux-preprocess-maybe
(org-publish-org-to utf8 plist filename pub-dir)))
 
+(defun org-publish-org-to-taskjuggler (plist filename pub-dir)
+  Publish an org file to TaskJuggler.
+See `org-publish-org-to' to the list of arguments.
+  (org-publish-with-aux-preprocess-maybe
+   (org-publish-org-to taskjuggler plist filename pub-dir)))
+
 (defun org-publish-attachment (plist filename pub-dir)
   Publish a file with no transformation of any kind.
 See `org-publish-org-to' to the list of arguments.
diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index 49c24ff..1733fe8 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -298,7 +298,8 @@ but before any resource and task declarations.
 (defvar org-export-taskjuggler-old-level)
 
 ;;;###autoload
-(defun org-export-as-taskjuggler ()
+(defun org-export-as-taskjuggler (optional arg hidden ext-plist
+   to-buffer body-only pub-dir)
   Export parts of the current buffer as a TaskJuggler file.
 The exporter looks for a tree with tag, property or todo that
 matches `org-export-taskjuggler-project-tag' and takes this as
@@ -310,11 +311,12 @@ resources for the project.  If no resources are 
specified, a
 default resource is created and allocated to the project.  Also
 the taskjuggler project will be created with default reports as
 defined in `org-export-taskjuggler-default-reports'.
-  (interactive)
+  (interactive P)
 
   (message Exporting...)
   (setq-default org-done-keywords org-done-keywords)
   (let* ((opt-plist (org-combine-plists (org-default-export-plist)
+   ext-plist
 (org-infile-export-plist)))
 (org-export-opt-plist opt-plist)
  (tasks
@@ -333,12 +335,20 @@ defined in `org-export-taskjuggler-default-reports'.
  (org-map-entries
   'org-taskjuggler-components
   org-export-taskjuggler-report-tag nil 'archive 'comment))
-(filename (expand-file-name
-   (concat
-(file-name-sans-extension
- (file-name-nondirectory buffer-file-name))
-org-export-taskjuggler-extension)))
-(buffer (find-file-noselect filename))
+(filename (if to-buffer
+  nil
+(concat (file-name-as-directory
+ (or pub-dir
+ (org-export-directory :tj opt-plist)))
+(file-name-sans-extension
+ (file-name-nondirectory buffer-file-name))
+org-export-taskjuggler-extension)))
+(buffer (if to-buffer
+(cond
+ ((eq to-buffer 'string)
+  (get-buffer-create *Org Taskjuggler Export*))
+ (t (get-buffer-create to-buffer)))
+  (find-file-noselect filename)))
 (old-buffer (current-buffer))
 (org-export-taskjuggler-old-level 0)
 task resource)
@@ -399,10 +409,13 @@ defined in `org-export-taskjuggler-default-reports'.
(if org-export-taskjuggler-keep-project-as-task
   1 2))
   (org-taskjuggler-insert-reports reports)
-  (save-buffer)
+  (or to-buffer (save-buffer))
   (or (org-export-push-to-kill-ring TaskJuggler)
  (message Exporting... done))
-  (current-buffer
+  (if (eq to-buffer 'string)
+ (prog1 (buffer-substring (point-min) (point-max))
+   (kill-buffer (current-buffer)))
+   (current-buffer)
 
 ;;;###autoload
 (defun org-export-as-taskjuggler-and-open ()
-- 
1.7.11.4




[O] [PATCH 04/10] org-taskjuggler: task with end-only is also a milestone (deadline)

2012-08-15 Thread Yann Hodique
---
 lisp/org-taskjuggler.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index 7974d1e..f668e7f 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -689,7 +689,8 @@ org-mode priority string.
(and (assoc leaf-node task)
 (not (or effort
  (cdr (assoc duration task))
- (cdr (assoc end task))
+ (and (cdr (assoc start task))
+  (cdr (assoc end task)))
  (cdr (assoc period task)))
 (attributes org-export-taskjuggler-valid-task-attributes))
 (insert
-- 
1.7.11.3




[O] [PATCH v2 04/11] org-taskjuggler: fix milestone definition

2012-08-15 Thread Yann Hodique
* org-taskjuggler.el (org-taskjuggler-open-task): task with end-only is also
a milestone (deadline), task with length is not
---
 lisp/org-taskjuggler.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index 93f0cc7..a18cdf8 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -689,8 +689,10 @@ org-mode priority string.
 (milestone (or (cdr (assoc milestone task))
(and (assoc leaf-node task)
 (not (or effort
+ (cdr (assoc length task))
  (cdr (assoc duration task))
- (cdr (assoc end task))
+ (and (cdr (assoc start task))
+  (cdr (assoc end task)))
  (cdr (assoc period task)))
 (attributes org-export-taskjuggler-valid-task-attributes))
 (insert
-- 
1.7.11.4




[O] [PATCH v2 09/11] org-taskjuggler: allow reports definition from within the org file

2012-08-15 Thread Yann Hodique
* org-taskjuggler.el (org-export-taskjuggler-report-tag): new custom variable
(org-export-taskjuggler-valid-report-attributes): new custom variable
(org-export-as-taskjuggler): compute reports
(org-taskjuggler-open-report): generate report from org item
(org-taskjuggler-insert-reports): insert default reports only if no explicit
one is defined
---
 lisp/org-taskjuggler.el | 42 +-
 1 file changed, 37 insertions(+), 5 deletions(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index 33b111d..49c24ff 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -181,6 +181,13 @@ resources for the project.
   :version 24.1
   :type 'string)
 
+(defcustom org-export-taskjuggler-report-tag taskjuggler_report
+  Tag, property or todo used to find the tree containing all the
+reports for the project.
+  :group 'org-export-taskjuggler
+  :version 24.1
+  :type 'string)
+
 (defcustom org-export-taskjuggler-target-version 2.4
   Which version of TaskJuggler the exporter is targeting.
   :group 'org-export-taskjuggler
@@ -264,6 +271,14 @@ but before any resource and task declarations.
   the corresponding resource.
   :group 'org-export-taskjuggler)
 
+(defcustom org-export-taskjuggler-valid-report-attributes
+  '(headline columns definitions timeformat hideresource hidetask
+loadunit sorttasks formats period)
+  Valid attributes for Taskjuggler reports. If one of these
+  appears as a property for a headline, it will be exported with
+  the corresponding report.
+  :group 'org-export-taskjuggler)
+
 (defcustom org-export-taskjuggler-keep-project-as-task t
   Whether to keep the project headline as an umbrella task for
   all declared tasks. Setting this to nil will allow maintaining
@@ -314,6 +329,10 @@ defined in `org-export-taskjuggler-default-reports'.
   (org-map-entries
'org-taskjuggler-components
org-export-taskjuggler-resource-tag nil 'archive 'comment)))
+(reports
+ (org-map-entries
+  'org-taskjuggler-components
+  org-export-taskjuggler-report-tag nil 'archive 'comment))
 (filename (expand-file-name
(concat
 (file-name-sans-extension
@@ -379,7 +398,7 @@ defined in `org-export-taskjuggler-default-reports'.
   (org-taskjuggler-close-maybe
(if org-export-taskjuggler-keep-project-as-task
   1 2))
-  (org-taskjuggler-insert-reports)
+  (org-taskjuggler-insert-reports reports)
   (save-buffer)
   (or (org-export-push-to-kill-ring TaskJuggler)
  (message Exporting... done))
@@ -741,6 +760,16 @@ org-mode priority string.
   (org-taskjuggler-get-attributes task attributes)
   \n
 
+(defun org-taskjuggler-open-report (report)
+  (let* ((kind (or (cdr (assoc report-kind report)) taskreport))
+(headline (cdr (assoc HEADLINE report)))
+(attributes org-export-taskjuggler-valid-report-attributes))
+(insert
+ (concat
+  kind  \ headline \ {\n
+  (org-taskjuggler-get-attributes report attributes)
+  \n}\n
+
 (defun org-taskjuggler-close-maybe (level)
   (while ( org-export-taskjuggler-old-level level)
 (insert }\n)
@@ -748,10 +777,13 @@ org-mode priority string.
   (when (= org-export-taskjuggler-old-level level)
 (insert }\n)))
 
-(defun org-taskjuggler-insert-reports ()
-  (let (report)
-(dolist (report org-export-taskjuggler-default-reports)
-  (insert report \n
+(defun org-taskjuggler-insert-reports (reports)
+  (if reports
+  (dolist (report (cdr reports))
+   (org-taskjuggler-open-report report))
+(let (report)
+  (dolist (report org-export-taskjuggler-default-reports)
+   (insert report \n)
 
 (provide 'org-taskjuggler)
 
-- 
1.7.11.4




[O] [PATCH v2 08/11] org-taskjuggler: disambiguate headline, as it's also a valid property

2012-08-15 Thread Yann Hodique
---
 lisp/org-taskjuggler.el | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index 3c97e03..33b111d 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -329,7 +329,7 @@ defined in `org-export-taskjuggler-default-reports'.
 (unless resources
   (setq resources
`(((resource_id . ,(user-login-name))
-  (headline . ,user-full-name)
+  (HEADLINE . ,user-full-name)
   (level . 1)
 ;; add a default allocation to the first task if none was given
 (unless (assoc allocate (car tasks))
@@ -427,7 +427,7 @@ information, all the properties, etc.
   (when deadline
(push (cons end (org-taskjuggler-date (cdr deadline))) props)))
 (push (cons level level) props)
-(push (cons headline headline) props)
+(push (cons HEADLINE headline) props)
 (push (cons parent-ordered parent-ordered) props)))
 
 (defun org-taskjuggler-assign-task-ids (tasks)
@@ -601,7 +601,7 @@ The id is derived from the headline and made unique against
 UNIQUE-IDS. If the (downcased) first token of the headline is not
 unique try to add more (downcased) tokens of the headline or
 finally add more underscore characters (\_\).
-  (let* ((headline (cdr (assoc headline item)))
+  (let* ((headline (cdr (assoc HEADLINE item)))
 (parts (split-string headline))
 (id (org-taskjuggler-clean-id (downcase (pop parts)
; try to add more parts of the headline 
to make it unique
@@ -627,7 +627,7 @@ attributes from the PROJECT alist are inserted.  If no end 
date is
 specified it is calculated
 `org-export-taskjuggler-default-project-duration' days from now.
   (let* ((unique-id (cdr (assoc unique-id project)))
-(headline (cdr (assoc headline project)))
+(headline (cdr (assoc HEADLINE project)))
 (version (cdr (assoc version project)))
 (start (cdr (assoc start project)))
 (end (cdr (assoc end project
@@ -678,7 +678,7 @@ is defined it will calculate a unique id for the resource 
using
 (or (cdr (assoc resource_id resource))
 (cdr (assoc ID resource))
 (cdr (assoc unique-id resource)
-   (headline (cdr (assoc headline resource)))
+   (headline (cdr (assoc HEADLINE resource)))
(attributes org-export-taskjuggler-valid-resource-attributes))
 (insert
  (concat
@@ -703,7 +703,7 @@ org-mode priority string.
 
 (defun org-taskjuggler-open-task (task)
   (let* ((unique-id (cdr (assoc unique-id task)))
-(headline (cdr (assoc headline task)))
+(headline (cdr (assoc HEADLINE task)))
 (effort (org-taskjuggler-clean-effort (cdr (assoc org-effort-property 
task
 (depends (cdr (assoc depends task)))
 (allocate (cdr (assoc allocate task)))
-- 
1.7.11.4




[O] [PATCH v2 07/11] org-taskjuggler: make project umbrella task optional

2012-08-15 Thread Yann Hodique
* org-taskjuggler.el (org-export-taskjuggler-keep-project-as-task): new custom
variable
(org-export-as-taskjuggler): optionally drop the topmost task (project)
(org-taskjuggler-assign-task-ids): adapt path computation by optionally
dropping the topmost component (project)

introduce `org-export-taskjuggler-keep-project-as-task' as a flag to toggle
the behavior. Keep old behavior as default.
---
 lisp/org-taskjuggler.el | 23 ---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index 7376302..3c97e03 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -264,6 +264,14 @@ but before any resource and task declarations.
   the corresponding resource.
   :group 'org-export-taskjuggler)
 
+(defcustom org-export-taskjuggler-keep-project-as-task t
+  Whether to keep the project headline as an umbrella task for
+  all declared tasks. Setting this to nil will allow maintaining
+  completely separated task buckets, while still sharing the same
+  resources pool.
+  :group 'org-export-taskjuggler
+  :type 'boolean)
+
 ;;; Hooks
 
 (defvar org-export-taskjuggler-final-hook nil
@@ -350,7 +358,10 @@ defined in `org-export-taskjuggler-default-reports'.
 
   (org-clone-local-variables old-buffer ^org-)
   (insert org-export-taskjuggler-default-global-header)
-  (org-taskjuggler-open-project (car tasks))
+  (org-taskjuggler-open-project
+   (if org-export-taskjuggler-keep-project-as-task
+  (car tasks)
+(pop tasks)))
   (insert org-export-taskjuggler-default-global-properties)
   (insert \n)
   (dolist (resource resources)
@@ -365,7 +376,9 @@ defined in `org-export-taskjuggler-default-reports'.
  (org-taskjuggler-close-maybe level)
  (org-taskjuggler-open-task task)
  (setq org-export-taskjuggler-old-level level)))
-  (org-taskjuggler-close-maybe 1)
+  (org-taskjuggler-close-maybe
+   (if org-export-taskjuggler-keep-project-as-task
+  1 2))
   (org-taskjuggler-insert-reports)
   (save-buffer)
   (or (org-export-push-to-kill-ring TaskJuggler)
@@ -446,7 +459,11 @@ a path to the current task.
  (push unique-id (car unique-ids))
  (setcar path unique-id)))
(push (cons unique-id unique-id) task)
-   (push (cons path (mapconcat 'identity (reverse path) .)) task)
+   (push (cons path
+   (mapconcat 'identity
+  (if org-export-taskjuggler-keep-project-as-task
+  (reverse path)
+(cdr (reverse path))) .)) task)
(setq previous-level level)
(setq resolved-tasks (append resolved-tasks (list task)))
 
-- 
1.7.11.4




Re: [O] [PATCH 07/10] org-taskjuggler: make project umbrella task optional

2012-08-12 Thread Yann Hodique
 Christian == Christian Egli christian.e...@sbs.ch writes:

 Yann Hodique yann.hodi...@gmail.com writes:
 +(defcustom org-export-taskjuggler-keep-project-as-task t
 +  Whether to keep the project headline as an umbrella task for
 +  all declared tasks. Setting this to nil will allow maintaining
 +  completely separated task buckets, while still sharing the same
 +  resources pool.

 I'm trying to understand the use case here. If I understand correctly
 the container headline will no longer unconditionally generate a root
 task. So you could have multiple root tasks? Does this work in both
 versions of tj?

Yes, basically the use case is the following.

From an org code like:
--8---cut here---start-8---
* Main :taskjuggler_project:
** Task1
** Task2
--8---cut here---end---8---

the default behavior is to generate something like
--8---cut here---start-8---
project main Main (}
task main Main {
  task task1 Task1 {}
  task task2 Task2 {}
}
--8---cut here---end---8---

leading to a report like
--8---cut here---start-8---
1. Main
1.1 Task1
1.2 Taks2
--8---cut here---end---8---

while the new (non-default) one would generate
--8---cut here---start-8---
project main Main {}
task task1 Task1 {}
task task2 Task2 {}
--8---cut here---end---8---

leading to a report like
--8---cut here---start-8---
1 Task1
2 Task2
--8---cut here---end---8---

I must confess this is mostly a way to avoid questions from people
looking at the report, asking why my task numbers are all 1.x :)

AFAICT it seems to work fine with either tj2 or tj3. I'm using tj3 only
myself, but the UI of tj2 doesn't complain at all about those multiple
root tasks.

Thanks,

Yann

-- 
When faced with necessary actions, there are always choices.  So long as the 
job gets done.

  -- COUNT HASIMIR FENRING, Dispatches from Arrakis




[O] [PATCH 00/10] Takjuggler exporter improvements

2012-08-05 Thread Yann Hodique
Here are a couple of patches for org-taskjuggler.el

My main goals with these were to:

 - be able to leverage SCHEDULE/DEADLINE information, so as to be able
   to leverage org timelines in complement to the reports

 - be able to #+BIND some of the exporter variables (such as the
   preamble)

 - be able to define reports in the org file itself, without having to
   mess with a custom variable

Any feedback is highly welcome.

Thanks,
Yann.


Yann Hodique (10):
  org-taskjuggler: make task and resource properties customizable
  org-taskjuggler: properly install local variables at export time
  org-taskjuggler: make use of org properties
  org-taskjuggler: task with end-only is also a milestone (deadline)
  org-taskjuggler: introduce a global header, for early macros
  org-taskjuggler: use project end date, if specified
  org-taskjuggler: make project umbrella task optional
  org-taskjuggler: disambiguate headline, as it's also a valid
taskjuggler property
  org-taskjuggler: allow reports definition from within the org file
  org-taskjuggler: update doc to reflect latest changes

 doc/org.texi|  48 ++--
 lisp/org-taskjuggler.el | 145 +++-
 2 files changed, 149 insertions(+), 44 deletions(-)

-- 
1.7.11.3




[O] [PATCH 01/10] org-taskjuggler: make task and resource properties customizable

2012-08-05 Thread Yann Hodique
* org-taskjuggler.el (org-export-taskjuggler-valid-task-attributes): new custom 
variable
 (org-export-taskjuggler-valid-resource-attributes): new custom variable
---
 lisp/org-taskjuggler.el | 25 +++--
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index 4409013..3c56630 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -240,6 +240,23 @@ but before any resource and task declarations.
   :version 24.1
   :type '(string :tag Preamble))
 
+(defcustom org-export-taskjuggler-valid-task-attributes
+  '(account start note duration endbuffer endcredit end
+   flags journalentry length limits maxend maxstart minend
+   minstart period reference responsible scheduling
+   startbuffer startcredit statusnote)
+  Valid attributes for Taskjuggler tasks. If one of these
+  appears as a property for a headline, it will be exported with
+  the corresponding task.
+  :group 'org-export-taskjuggler)
+
+(defcustom org-export-taskjuggler-valid-resource-attributes
+  '(limits vacation shift booking efficiency journalentry rate)
+  Valid attributes for Taskjuggler resources. If one of these
+  appears as a property for a headline, it will be exported with
+  the corresponding resource.
+  :group 'org-export-taskjuggler)
+
 ;;; Hooks
 
 (defvar org-export-taskjuggler-final-hook nil
@@ -614,7 +631,7 @@ is defined it will calculate a unique id for the resource 
using
 (cdr (assoc ID resource))
 (cdr (assoc unique-id resource)
(headline (cdr (assoc headline resource)))
-   (attributes '(limits vacation shift booking efficiency journalentry 
rate)))
+   (attributes org-export-taskjuggler-valid-resource-attributes))
 (insert
  (concat
   resource  id  \ headline \ {\n 
@@ -655,11 +672,7 @@ org-mode priority string.
  (cdr (assoc duration task))
  (cdr (assoc end task))
  (cdr (assoc period task)))
-(attributes
- '(account start note duration endbuffer endcredit end
-   flags journalentry length maxend maxstart minend
-   minstart period reference responsible scheduling
-   startbuffer startcredit statusnote)))
+(attributes org-export-taskjuggler-valid-task-attributes))
 (insert
  (concat
   task  unique-id  \ headline \ {\n
-- 
1.7.11.3




[O] [PATCH 05/10] org-taskjuggler: introduce a global header, for early macros

2012-08-05 Thread Yann Hodique
* org-taskjuggler.el (org-export-taskjuggler-default-global-header): new custom 
variable
 (org-export-as-taskjuggler): insert global header before anything else
---
 lisp/org-taskjuggler.el | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index f668e7f..3f829b3 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -221,6 +221,14 @@ with `org-export-taskjuggler-project-tag'
   :version 24.1
   :type '(repeat (string :tag Report)))
 
+(defcustom org-export-taskjuggler-default-global-header
+  
+  Default global header for the project. This goes before
+project declaration, and might be useful for early macros
+  :group 'org-export-taskjuggler
+  :version 24.1
+  :type '(string :tag Preamble))
+
 (defcustom org-export-taskjuggler-default-global-properties
   shift s40 \Part time shift\ {
   workinghours wed, thu, fri off
@@ -331,11 +339,6 @@ defined in `org-export-taskjuggler-default-reports'.
(setcar tasks (push (cons version version) task
 (with-current-buffer buffer
   (erase-buffer)
-  (org-clone-local-variables old-buffer ^org-)
-  (org-taskjuggler-open-project (car tasks))
-  (insert org-export-taskjuggler-default-global-properties)
-  (insert \n)
-  (dolist (resource resources)
   (org-install-letbind)
   ;; create local variables for all options, to make sure all called
   ;; functions get the correct information
@@ -344,6 +347,12 @@ defined in `org-export-taskjuggler-default-reports'.
(plist-get opt-plist (car x
 org-export-plist-vars)
 
+  (org-clone-local-variables old-buffer ^org-)
+  (insert org-export-taskjuggler-default-global-header)
+  (org-taskjuggler-open-project (car tasks))
+  (insert org-export-taskjuggler-default-global-properties)
+  (insert \n)
+  (dolist (resource resources)
(let ((level (cdr (assoc level resource
  (org-taskjuggler-close-maybe level)
  (org-taskjuggler-open-resource resource)
-- 
1.7.11.3




[O] [PATCH 06/10] org-taskjuggler: use project end date, if specified

2012-08-05 Thread Yann Hodique
* org-taskjuggler.el (org-taskjuggler-open-project): use START - END as an 
alternative to START +Xd
---
 lisp/org-taskjuggler.el | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index 3f829b3..92ba79c 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -614,9 +614,11 @@ specified it is calculated
 (start (cdr (assoc start project)))
 (end (cdr (assoc end project
 (insert
- (format project %s \%s\ \%s\ %s +%sd {\n }\n
+ (format project %s \%s\ \%s\ %s %s {\n }\n
 unique-id headline version start
-org-export-taskjuggler-default-project-duration
+ (or (and end (format - %s end))
+ (format +%sd
+ org-export-taskjuggler-default-project-duration))
 
 (defun org-taskjuggler-filter-and-join (items)
   Filter all nil elements from ITEMS and join the remaining ones
-- 
1.7.11.3




[O] [PATCH 02/10] org-taskjuggler: properly install local variables at export time

2012-08-05 Thread Yann Hodique
* org-taskjuggler.el (org-export-as-taskjuggler): compute opt-plist, use 
`org-install-letbind'
---
 lisp/org-taskjuggler.el | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index 3c56630..102eabc 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -284,7 +284,10 @@ defined in `org-export-taskjuggler-default-reports'.
 
   (message Exporting...)
   (setq-default org-done-keywords org-done-keywords)
-  (let* ((tasks
+  (let* ((opt-plist (org-combine-plists (org-default-export-plist)
+(org-infile-export-plist)))
+(org-export-opt-plist opt-plist)
+ (tasks
  (org-taskjuggler-resolve-dependencies
   (org-taskjuggler-assign-task-ids
(org-taskjuggler-compute-task-leafiness
@@ -335,6 +338,14 @@ defined in `org-export-taskjuggler-default-reports'.
   (insert org-export-taskjuggler-default-global-properties)
   (insert \n)
   (dolist (resource resources)
+  (org-install-letbind)
+  ;; create local variables for all options, to make sure all called
+  ;; functions get the correct information
+  (mapc (lambda (x)
+  (set (make-local-variable (nth 2 x))
+   (plist-get opt-plist (car x
+org-export-plist-vars)
+
(let ((level (cdr (assoc level resource
  (org-taskjuggler-close-maybe level)
  (org-taskjuggler-open-resource resource)
-- 
1.7.11.3




[O] [PATCH 10/10] org-taskjuggler: update doc to reflect latest changes

2012-08-05 Thread Yann Hodique
---
 doc/org.texi | 48 ++--
 1 file changed, 30 insertions(+), 18 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index 8613793..53e001b 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -11882,9 +11882,9 @@ nodes of a document or strictly follow the order of the 
nodes in the
 document.
 
 Instead the TaskJuggler exporter looks for a tree that defines the tasks and
-a optionally tree that defines the resources for this project.  It then
-creates a TaskJuggler file based on these trees and the attributes defined in
-all the nodes.
+optionally trees that define the resources and reports for this project.
+It then creates a TaskJuggler file based on these trees and the attributes
+defined in all the nodes.
 
 @subsection TaskJuggler export commands
 
@@ -11893,7 +11893,8 @@ all the nodes.
 Export as a TaskJuggler file.
 
 @orgcmd{C-c C-e J,org-export-as-taskjuggler-and-open}
-Export as a TaskJuggler file and then open the file with TaskJugglerUI.
+Export as a TaskJuggler file and then open the file with TaskJugglerUI (only
+for TaskJugglerUI 2.x).
 @end table
 
 @subsection Tasks
@@ -11931,15 +11932,17 @@ time.
 
 @subsection Export of properties
 
-The exporter also takes TODO state information into consideration, i.e.@: if a
-task is marked as done it will have the corresponding attribute in
-TaskJuggler (@samp{complete 100}).  Also it will export any property on a task
-resource or resource node which is known to TaskJuggler, such as
-@samp{limits}, @samp{vacation}, @samp{shift}, @samp{booking},
-@samp{efficiency}, @samp{journalentry}, @samp{rate} for resources or
-@samp{account}, @samp{start}, @samp{note}, @samp{duration}, @samp{end},
-@samp{journalentry}, @samp{milestone}, @samp{reference}, @samp{responsible},
-@samp{scheduling}, etc for tasks.
+The exporter also takes TODO state information into consideration, i.e.@: if
+a task is marked as done it will have the corresponding attribute in
+TaskJuggler (@samp{complete 100}).  Scheduling information is also taken into
+account to set start/end dates for tasks.
+
+The exporter will also export any property on a task resource or resource
+node which is known to TaskJuggler, such as @samp{limits}, @samp{vacation},
+@samp{shift}, @samp{booking}, @samp{efficiency}, @samp{journalentry},
+@samp{rate} for resources or @samp{account}, @samp{start}, @samp{note},
+@samp{duration}, @samp{end}, @samp{journalentry}, @samp{milestone},
+@samp{reference}, @samp{responsible}, @samp{scheduling}, etc for tasks.
 
 @subsection Dependencies
 
@@ -11985,11 +11988,20 @@ examples should illustrate this:
 @vindex org-export-taskjuggler-default-reports
 TaskJuggler can produce many kinds of reports (e.g.@: gantt chart, resource
 allocation, etc).  The user defines what kind of reports should be generated
-for a project in the TaskJuggler file.  The exporter will automatically insert
-some default reports in the file.  These defaults are defined in
-@code{org-export-taskjuggler-default-reports}.  They can be modified using
-customize along with a number of other options.  For a more complete list, see
-@kbd{M-x customize-group @key{RET} org-export-taskjuggler @key{RET}}.
+for a project in the TaskJuggler file.  By default, the exporter will
+automatically insert some pre-set reports in the file.  These defaults are
+defined in @code{org-export-taskjuggler-default-reports}.  They can be
+modified using customize along with a number of other options.  For a more
+complete list, see @kbd{M-x customize-group @key{RET} org-export-taskjuggler
+@key{RET}}.
+
+Alternately, the user can tag a tree with
+@code{org-export-taskjuggler-report-tag}, and define reports in sub-nodes,
+similarly to what is done with tasks or resources.  The properties used for
+report generation are defined in
+@code{org-export-taskjuggler-valid-report-attributes}. In addition, a special
+property named @samp{report-kind} is used to define the kind of report one
+wants to generate (by default, a @samp{taskreport}).
 
 For more information and examples see the Org-taskjuggler tutorial at
 @uref{http://orgmode.org/worg/org-tutorials/org-taskjuggler.html}.
-- 
1.7.11.3




[O] [PATCH 09/10] org-taskjuggler: allow reports definition from within the org file

2012-08-05 Thread Yann Hodique
This renders reports production much more flexible.

* org-taskjuggler.el (org-export-taskjuggler-report-tag): new custom variable
 (org-export-taskjuggler-valid-report-attributes): new custom variable
 (org-export-as-taskjuggler): compute reports
 (org-taskjuggler-open-report): generate report from org item
 (org-taskjuggler-insert-reports): insert default reports only if no explicit 
one is defined
---
 lisp/org-taskjuggler.el | 42 +-
 1 file changed, 37 insertions(+), 5 deletions(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index b08dcdf..ad1873a 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -181,6 +181,13 @@ resources for the project.
   :version 24.1
   :type 'string)
 
+(defcustom org-export-taskjuggler-report-tag taskjuggler_report
+  Tag, property or todo used to find the tree containing all the
+reports for the project.
+  :group 'org-export-taskjuggler
+  :version 24.1
+  :type 'string)
+
 (defcustom org-export-taskjuggler-target-version 2.4
   Which version of TaskJuggler the exporter is targeting.
   :group 'org-export-taskjuggler
@@ -263,6 +270,14 @@ but before any resource and task declarations.
   the corresponding resource.
   :group 'org-export-taskjuggler)
 
+(defcustom org-export-taskjuggler-valid-report-attributes
+  '(headline columns definitions timeformat hideresource hidetask
+loadunit sorttasks formats)
+  Valid attributes for Taskjuggler reports. If one of these
+  appears as a property for a headline, it will be exported with
+  the corresponding report.
+  :group 'org-export-taskjuggler)
+
 (defcustom org-export-taskjuggler-keep-project-as-task t
   Whether to keep the project headline as an umbrella task for
   all declared tasks. Setting this to nil will allow maintaining
@@ -313,6 +328,10 @@ defined in `org-export-taskjuggler-default-reports'.
   (org-map-entries
'org-taskjuggler-components
org-export-taskjuggler-resource-tag nil 'archive 'comment)))
+(reports
+ (org-map-entries
+  'org-taskjuggler-components
+  org-export-taskjuggler-report-tag nil 'archive 'comment))
 (filename (expand-file-name
(concat
 (file-name-sans-extension
@@ -378,7 +397,7 @@ defined in `org-export-taskjuggler-default-reports'.
   (org-taskjuggler-close-maybe
(if org-export-taskjuggler-keep-project-as-task
   1 2))
-  (org-taskjuggler-insert-reports)
+  (org-taskjuggler-insert-reports reports)
   (save-buffer)
   (or (org-export-push-to-kill-ring TaskJuggler)
  (message Exporting... done))
@@ -739,6 +758,16 @@ org-mode priority string.
   (org-taskjuggler-get-attributes task attributes)
   \n
 
+(defun org-taskjuggler-open-report (report)
+  (let* ((kind (or (cdr (assoc report-kind report)) taskreport))
+(headline (cdr (assoc HEADLINE report)))
+(attributes org-export-taskjuggler-valid-report-attributes))
+(insert
+ (concat
+  kind  \ headline \ {\n
+  (org-taskjuggler-get-attributes report attributes)
+  \n}\n
+
 (defun org-taskjuggler-close-maybe (level)
   (while ( org-export-taskjuggler-old-level level)
 (insert }\n)
@@ -746,10 +775,13 @@ org-mode priority string.
   (when (= org-export-taskjuggler-old-level level)
 (insert }\n)))
 
-(defun org-taskjuggler-insert-reports ()
-  (let (report)
-(dolist (report org-export-taskjuggler-default-reports)
-  (insert report \n
+(defun org-taskjuggler-insert-reports (reports)
+  (if reports
+  (dolist (report (cdr reports))
+   (org-taskjuggler-open-report report))
+(let (report)
+  (dolist (report org-export-taskjuggler-default-reports)
+   (insert report \n)
 
 (provide 'org-taskjuggler)
 
-- 
1.7.11.3




[O] [PATCH 08/10] org-taskjuggler: disambiguate headline, as it's also a valid taskjuggler property

2012-08-05 Thread Yann Hodique
---
 lisp/org-taskjuggler.el | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index 996665d..b08dcdf 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -328,7 +328,7 @@ defined in `org-export-taskjuggler-default-reports'.
 (unless resources
   (setq resources
`(((resource_id . ,(user-login-name))
-  (headline . ,user-full-name)
+  (HEADLINE . ,user-full-name)
   (level . 1)
 ;; add a default allocation to the first task if none was given
 (unless (assoc allocate (car tasks))
@@ -426,7 +426,7 @@ information, all the properties, etc.
   (when deadline
(push (cons end (org-taskjuggler-date (cdr deadline))) props)))
 (push (cons level level) props)
-(push (cons headline headline) props)
+(push (cons HEADLINE headline) props)
 (push (cons parent-ordered parent-ordered) props)))
 
 (defun org-taskjuggler-assign-task-ids (tasks)
@@ -600,7 +600,7 @@ The id is derived from the headline and made unique against
 UNIQUE-IDS. If the (downcased) first token of the headline is not
 unique try to add more (downcased) tokens of the headline or
 finally add more underscore characters (\_\).
-  (let* ((headline (cdr (assoc headline item)))
+  (let* ((headline (cdr (assoc HEADLINE item)))
 (parts (split-string headline))
 (id (org-taskjuggler-clean-id (downcase (pop parts)
 ; try to add more parts of the headline to make it unique
@@ -626,7 +626,7 @@ attributes from the PROJECT alist are inserted. If no end 
date is
 specified it is calculated
 `org-export-taskjuggler-default-project-duration' days from now.
   (let* ((unique-id (cdr (assoc unique-id project)))
-(headline (cdr (assoc headline project)))
+(headline (cdr (assoc HEADLINE project)))
 (version (cdr (assoc version project)))
 (start (cdr (assoc start project)))
 (end (cdr (assoc end project
@@ -677,7 +677,7 @@ is defined it will calculate a unique id for the resource 
using
 (or (cdr (assoc resource_id resource))
 (cdr (assoc ID resource))
 (cdr (assoc unique-id resource)
-   (headline (cdr (assoc headline resource)))
+   (headline (cdr (assoc HEADLINE resource)))
(attributes org-export-taskjuggler-valid-resource-attributes))
 (insert
  (concat
@@ -702,7 +702,7 @@ org-mode priority string.
 
 (defun org-taskjuggler-open-task (task)
   (let* ((unique-id (cdr (assoc unique-id task)))
-(headline (cdr (assoc headline task)))
+(headline (cdr (assoc HEADLINE task)))
 (effort (org-taskjuggler-clean-effort (cdr (assoc org-effort-property 
task
 (depends (cdr (assoc depends task)))
 (allocate (cdr (assoc allocate task)))
-- 
1.7.11.3




[O] [PATCH 04/10] org-taskjuggler: task with end-only is also a milestone (deadline)

2012-08-05 Thread Yann Hodique
---
 lisp/org-taskjuggler.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index 7974d1e..f668e7f 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -689,7 +689,8 @@ org-mode priority string.
(and (assoc leaf-node task)
 (not (or effort
  (cdr (assoc duration task))
- (cdr (assoc end task))
+ (and (cdr (assoc start task))
+  (cdr (assoc end task)))
  (cdr (assoc period task)))
 (attributes org-export-taskjuggler-valid-task-attributes))
 (insert
-- 
1.7.11.3




[O] [PATCH 03/10] org-taskjuggler: make use of org properties

2012-08-05 Thread Yann Hodique
infer start and end date from SCHEDULED/DEADLINE information

* org-taskjuggler.el (org-taskjuggler-date): new function, produce a 
taskjuggler-compatible date
 (org-taskjuggler-components): make use of SCHEDULED/DEADLINE properties
---
 lisp/org-taskjuggler.el | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index 102eabc..7974d1e 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -138,8 +138,6 @@
 ;;   :END:
 ;;
  * TODO
-;;   - Use SCHEDULED and DEADLINE information (not just start and end
-;; properties).
 ;;   - Look at org-file-properties, org-global-properties and
 ;; org-global-properties-fixed
 ;;   - What about property inheritance and org-property-inherit-p?
@@ -384,6 +382,10 @@ with the TaskJuggler GUI.
   (save-excursion
 (and (org-up-heading-safe) (org-entry-get (point) ORDERED
 
+(defun org-taskjuggler-date (date)
+  (let ((time (parse-time-string date)))
+(format %d-%02d-%02d (nth 5 time) (nth 4 time) (nth 3 time
+
 (defun org-taskjuggler-components ()
   Return an alist containing all the pertinent information for
 the current node such as the headline, the level, todo state
@@ -395,6 +397,12 @@ information, all the properties, etc.
  (replace-regexp-in-string
   \ \\\ (nth 4 components) t t)) ; quote double quotes in 
headlines
 (parent-ordered (org-taskjuggler-parent-is-ordered-p)))
+(let ((scheduled (assoc SCHEDULED props))
+ (deadline (assoc DEADLINE props)))
+  (when scheduled
+   (push (cons start (org-taskjuggler-date (cdr scheduled))) props))
+  (when deadline
+   (push (cons end (org-taskjuggler-date (cdr deadline))) props)))
 (push (cons level level) props)
 (push (cons headline headline) props)
 (push (cons parent-ordered parent-ordered) props)))
-- 
1.7.11.3




[O] [PATCH 07/10] org-taskjuggler: make project umbrella task optional

2012-08-05 Thread Yann Hodique
introduce `org-export-taskjuggler-keep-project-as-task' as a flag to toggle
the behavior. Keep old behavior as default.

* org-taskjuggler.el (org-export-taskjuggler-keep-project-as-task): new custom 
variable
 (org-export-as-taskjuggler): optionally drop the topmost task (project)
 (org-taskjuggler-assign-task-ids): adapt path computation by optionally 
dropping the topmost component (project)
---
 lisp/org-taskjuggler.el | 23 ---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index 92ba79c..996665d 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -263,6 +263,14 @@ but before any resource and task declarations.
   the corresponding resource.
   :group 'org-export-taskjuggler)
 
+(defcustom org-export-taskjuggler-keep-project-as-task t
+  Whether to keep the project headline as an umbrella task for
+  all declared tasks. Setting this to nil will allow maintaining
+  completely separated task buckets, while still sharing the same
+  resources pool.
+  :group 'org-export-taskjuggler
+  :type 'boolean)
+
 ;;; Hooks
 
 (defvar org-export-taskjuggler-final-hook nil
@@ -349,7 +357,10 @@ defined in `org-export-taskjuggler-default-reports'.
 
   (org-clone-local-variables old-buffer ^org-)
   (insert org-export-taskjuggler-default-global-header)
-  (org-taskjuggler-open-project (car tasks))
+  (org-taskjuggler-open-project
+   (if org-export-taskjuggler-keep-project-as-task
+  (car tasks)
+(pop tasks)))
   (insert org-export-taskjuggler-default-global-properties)
   (insert \n)
   (dolist (resource resources)
@@ -364,7 +375,9 @@ defined in `org-export-taskjuggler-default-reports'.
  (org-taskjuggler-close-maybe level)
  (org-taskjuggler-open-task task)
  (setq org-export-taskjuggler-old-level level)))
-  (org-taskjuggler-close-maybe 1)
+  (org-taskjuggler-close-maybe
+   (if org-export-taskjuggler-keep-project-as-task
+  1 2))
   (org-taskjuggler-insert-reports)
   (save-buffer)
   (or (org-export-push-to-kill-ring TaskJuggler)
@@ -445,7 +458,11 @@ a path to the current task.
  (push unique-id (car unique-ids))
  (setcar path unique-id)))
(push (cons unique-id unique-id) task)
-   (push (cons path (mapconcat 'identity (reverse path) .)) task)
+   (push (cons path
+   (mapconcat 'identity
+  (if org-export-taskjuggler-keep-project-as-task
+  (reverse path)
+(cdr (reverse path))) .)) task)
(setq previous-level level)
(setq resolved-tasks (append resolved-tasks (list task)))
 
-- 
1.7.11.3




Re: [O] [PATCH 00/10] Takjuggler exporter improvements

2012-08-05 Thread Yann Hodique
 Bastien == Bastien  b...@gnu.org writes:

 Hi Yann,
 Yann Hodique yann.hodi...@gmail.com writes:

 Here are a couple of patches for org-taskjuggler.el

 thanks for this.  I've quickly check by just reading the patches,
 and this looks good.  I copy Christian, hoping he will have time
 to double-check.

 Did you sign the FSF papers?  

Hi Bastien,

Thanks for the quick feedback.

I did sign FSF papers a few years ago, but not sure Emacs was explicitly
in the scope. Anyway, I just sent another form to be sure.

 Also, please reread http://orgmode.org/worg/org-contribute.html#sec-5 
 to format the commit messages more appropriately.

Ok. I'll wait a bit for potential feedback from Christian and rework
the messages.

Thanks,

Yann.

-- 
The surest way to keep a secret is to make
people believe they already know the answer.

  -- Ancient Fremen Wisdom



[Orgmode] Re: s5 presentation

2010-11-11 Thread Yann Hodique
 Dov == Dov Grobgeld dov.grobg...@gmail.com writes:

 Great! Thanks! Finally got it working.
 Next question. Is it possible to get syntax highlighting in s5/org? This
 might be more related to s5 than to s5-org though.

Sure, but it's actually an org-mode question :)

 #+SETUPFILE: s5.org
 #+TITLE: Perl
 #+AUTHOR: Dov Grobgeld
 #+BIND: org-s5-html-preamble-footer h1A perl test/h1

 * Perl
 - A simple perl program

 #+begin_src perl
   #!/usr/bin/perl
   while() {
   print $.: $_;
   }
 #+end_src

Well, it just works for me. The HTML export takes care of highlighting
code blocks (probably using htmlize or something similar). Then org-s5
doesn't transform at all those parts of the document.

In your case I'd say that probably the source code exporter might fail
for whatever reason. Is it doing the right thing for regular HTML
export ?

Alternately, I might have configured something somewhere to have code
highlighting enabled, but I can't remember :) (and definitely not
anything specific to org-s5). Anyway I suspect the problem is more on
the org-mode side this time, whatever it is.

Yann.

-- 
One uses power by grasping it lightly.  To grasp with too much force is to be 
taken over by power, thus becoming its victim.

  -- Bene Gesserit Axiom


___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] Re: s5 presentation

2010-11-10 Thread Yann Hodique
 Dov == Dov Grobgeld dov.grobg...@gmail.com writes:

 I tried to get the s5 presentation mode from
 https://github.com/sigma/org-s5running, but I'm missing something. I
 followed all the steps in the README,
 but how do you generate the S5:ified html? I tried simply doing [C-c C-e b]
 but it did not open up in s5 mode. What am I missing? Should the generated
 html contain the contents of preamble in org-s5.el? It does not.

Hi,

I'm the author of this little hack, so first thanks for your interest :)
You're right, the goal is to have it work by just exporting to html, so
C-c C-e b should just work.

I suspect that you might have not inserted the magic line
,
| #+SETUPFILE: s5.org
`
at the beginning of the file you're trying to export as s5.

Re-reading the README, I must admit it's far from being clear that the
magic comes from there... (will fix that immediately)

Does that help ?

Yann.

-- 
There is no escape--we pay for the violence of our ancestors. 

  -- from The Collected Sayings of Muad'Dib by the Princess Irulan


___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode