From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yann Hodique Subject: [PATCH 09/10] org-taskjuggler: allow reports definition from within the org file Date: Sun, 5 Aug 2012 12:54:03 +0200 Message-ID: <1344164044-15059-10-git-send-email-yann.hodique@gmail.com> References: <1344164044-15059-1-git-send-email-yann.hodique@gmail.com> Return-path: Received: from eggs.gnu.org ([208.118.235.92]:56513) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SxyUR-0001vf-4f for emacs-orgmode@gnu.org; Sun, 05 Aug 2012 06:55:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SxyUP-000124-Sp for emacs-orgmode@gnu.org; Sun, 05 Aug 2012 06:55:19 -0400 Received: from mail-we0-f169.google.com ([74.125.82.169]:33655) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SxyUP-0000qU-Mi for emacs-orgmode@gnu.org; Sun, 05 Aug 2012 06:55:17 -0400 Received: by mail-we0-f169.google.com with SMTP id s10so1558207wey.0 for ; Sun, 05 Aug 2012 03:55:17 -0700 (PDT) In-Reply-To: <1344164044-15059-1-git-send-email-yann.hodique@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Cc: 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