From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yann Hodique Subject: [PATCH v2 09/11] org-taskjuggler: allow reports definition from within the org file Date: Wed, 15 Aug 2012 21:11:55 +0200 Message-ID: <1345057917-69300-11-git-send-email-yann.hodique@gmail.com> References: <1345057917-69300-1-git-send-email-yann.hodique@gmail.com> Return-path: Received: from eggs.gnu.org ([208.118.235.92]:39671) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1j19-0005DA-NJ for emacs-orgmode@gnu.org; Wed, 15 Aug 2012 15:12:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T1j17-0002df-Ij for emacs-orgmode@gnu.org; Wed, 15 Aug 2012 15:12:35 -0400 Received: from mail-we0-f169.google.com ([74.125.82.169]:38760) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1j17-0002VT-Cd for emacs-orgmode@gnu.org; Wed, 15 Aug 2012 15:12:33 -0400 Received: by mail-we0-f169.google.com with SMTP id s10so1410328wey.0 for ; Wed, 15 Aug 2012 12:12:33 -0700 (PDT) In-Reply-To: <1345057917-69300-1-git-send-email-yann.hodique@gmail.com> In-Reply-To: <1344164044-15059-1-git-send-email-yann.hodique@gmail.com> References: <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 * 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