From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yann Hodique Subject: [PATCH v3 09/11] org-taskjuggler.el: Allow reports definition from within the org file Date: Thu, 16 Aug 2012 21:02:07 +0200 Message-ID: <1345143729-72705-10-git-send-email-yann.hodique@gmail.com> References: <1345057917-69300-1-git-send-email-yann.hodique@gmail.com> <1345143729-72705-1-git-send-email-yann.hodique@gmail.com> Return-path: Received: from eggs.gnu.org ([208.118.235.92]:48689) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T25LN-00075J-KO for emacs-orgmode@gnu.org; Thu, 16 Aug 2012 15:02:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T25LL-0001t9-RK for emacs-orgmode@gnu.org; Thu, 16 Aug 2012 15:02:57 -0400 Received: from mail-wg0-f49.google.com ([74.125.82.49]:53620) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T25LL-0001nq-M2 for emacs-orgmode@gnu.org; Thu, 16 Aug 2012 15:02:55 -0400 Received: by mail-wg0-f49.google.com with SMTP id ez12so2171108wgb.30 for ; Thu, 16 Aug 2012 12:02:55 -0700 (PDT) In-Reply-To: <1345143729-72705-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): 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