1

I'm using the taskjuggler export backend for org-mode. All works well except I cannot work out how to set some project global values. I want to set the follow for all my exported *.tjp files

timezone \"Australia/Sydney\"
dailyworkinghours 7
workinghours mon - fri 9:00 - 13:00, 14:00 - 17:00
workinghours sat, sun off

These settings need to go into the project header section i.e

project nil "Work" "1.0" 2015-02-01 +3y {
  timezone "Australia/Sydney"
  dailyworkinghours 7
  workinghours mon - fri 9:00 - 13:00, 14:00 - 17:00
  workinghours sat, sun off

}

However, I can't seem to find a way to do this. There are various custom settings, such as org-taskjuggler-default-global-header, but this inserts its value before the project header. There is also org-taskjuggler-default-global-properties, but it inserts the contents after the project block. Neither will suit as the parser for taskjuggler will not recognise the values correctly unless they are in the project header (well, they will recognise them if they are in each task, but I don't want to have to set these values for every task)

I've had a bit of a look at the ox-taskjuggler elisp code, but cannot find an easy way to do this.

I'm sure others have wanted to set/change the defaults, but I cannot see how to do this easily. Any ideas?

1

Without any knowledge of taskjuggler, I'd imagine there are several relatively easy options of producing that (or any text in any export back-end) using some general-purpose mechanism.

Dynamic blocks

http://orgmode.org/manual/Dynamic-blocks.html

I'll start with example:

#+BEGIN: gen-tjp-project :kind "Work" :version "0.1"
project nil "Work" "0.1" 15-02-16 +0200 {
  timezone "Australia/Sydney"
  dailyworkinghours 7
  workinghours mon - fri 9:00 - 13:00, 14:00 - 17:00
  workinghours sat, sun off

}
#+END:

(defun org-dblock-write:gen-tjp-project (params)
  (let ((template
         "project %s %S %S %s {
  timezone %S
  dailyworkinghours 7
  workinghours mon - fri 9:00 - 13:00, 14:00 - 17:00
  workinghours sat, sun off

}")
        (kind (plist-get params :kind))
        (version (plist-get params :version))
        (today (format-time-string "%y-%m-%d %z" (current-time)))
        (tz (or (plist-get params :tz) "Australia/Sydney")))
    (insert (format template nil kind version today tz))))

You can extend this template in a way that you see fit, this is just an example.

Babel with special template

(defun simple-template (key value fmt str)
  (replace-regexp-in-string
   (symbol-name key)
   (cl-case key
     (:now (format-time-string (or fmt "%y-%m-%d %z") (current-time)))
     (otherwise (format (or fmt "%s") value)))
   str))

(defun org-babel-execute:text (body params)
  (cl-loop for (key value fmt) in (cdr (assoc :extra params))
           for result = (simple-template key value fmt body)
           then (simple-template key value fmt result)
           finally (cl-return result)))

Example:

#+BEGIN_SRC text :results raw :extra '((:kind "%S" "Work") (:version "%S" "0.1") (:now))
project nil :kind :version :now {
  timezone "Australia/Sydney"
  dailyworkinghours 7
  workinghours mon - fri 9:00 - 13:00, 14:00 - 17:00
  workinghours sat, sun off
}
#+END_SRC

#+RESULTS:
project nil Work 0.1 15-02-16 +0200 {
  timezone "Australia/Sydney"
  dailyworkinghours 7
  workinghours mon - fri 9:00 - 13:00, 14:00 - 17:00
  workinghours sat, sun off
}

Where you could, of course, make simple-template smarter in a sense it would know more special keywords and how to replace them.

  • Thanks. Unfortunately, this won't work with the task juggler export backend. It is quite limited with respect to what it will export. Still, you have provided some ideas which I might look at as a possible replacement for using the existing task juggler exporter. – Tim X Feb 16 '15 at 4:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.