From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yann Hodique Subject: [PATCH v2 11/11] org-taskjuggler: make taskjuggler compatible with org-publish Date: Wed, 15 Aug 2012 21:11:57 +0200 Message-ID: <1345057917-69300-13-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]:39712) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1j1C-0005MD-Iu for emacs-orgmode@gnu.org; Wed, 15 Aug 2012 15:12:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T1j1B-0002f4-6V for emacs-orgmode@gnu.org; Wed, 15 Aug 2012 15:12:38 -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 1T1j1B-0002VT-07 for emacs-orgmode@gnu.org; Wed, 15 Aug 2012 15:12:37 -0400 Received: by mail-we0-f169.google.com with SMTP id s10so1410328wey.0 for ; Wed, 15 Aug 2012 12:12:36 -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 * 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