emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Yann Hodique <yann.hodique@gmail.com>
To: emacs-orgmode@gnu.org
Cc: Yann Hodique <yann.hodique@gmail.com>
Subject: [PATCH v2 11/11] org-taskjuggler: make taskjuggler compatible with org-publish
Date: Wed, 15 Aug 2012 21:11:57 +0200	[thread overview]
Message-ID: <1345057917-69300-13-git-send-email-yann.hodique@gmail.com> (raw)
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>

* 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

      parent reply	other threads:[~2012-08-15 19:12 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-05 10:53 [PATCH 00/10] Takjuggler exporter improvements Yann Hodique
2012-08-05 10:53 ` [PATCH 01/10] org-taskjuggler: make task and resource properties customizable Yann Hodique
2012-08-05 10:53 ` [PATCH 02/10] org-taskjuggler: properly install local variables at export time Yann Hodique
2012-08-05 10:53 ` [PATCH 03/10] org-taskjuggler: make use of org properties Yann Hodique
2012-08-05 10:53 ` [PATCH 04/10] org-taskjuggler: task with end-only is also a milestone (deadline) Yann Hodique
2012-08-05 10:53 ` [PATCH 05/10] org-taskjuggler: introduce a global header, for early macros Yann Hodique
2012-08-05 10:54 ` [PATCH 06/10] org-taskjuggler: use project end date, if specified Yann Hodique
2012-08-05 10:54 ` [PATCH 07/10] org-taskjuggler: make project umbrella task optional Yann Hodique
2012-08-10  5:30   ` Christian Egli
2012-08-12  8:03     ` Yann Hodique
2012-08-12 21:36       ` Simon Thum
2012-08-12 21:56         ` Bastien
2012-08-14  2:39       ` Christian Egli
2012-08-14  7:43         ` Bastien
2012-08-05 10:54 ` [PATCH 08/10] org-taskjuggler: disambiguate "headline", as it's also a valid taskjuggler property Yann Hodique
2012-08-05 10:54 ` [PATCH 09/10] org-taskjuggler: allow reports definition from within the org file Yann Hodique
2012-08-05 10:54 ` [PATCH 10/10] org-taskjuggler: update doc to reflect latest changes Yann Hodique
2012-08-05 17:29 ` [PATCH 00/10] Takjuggler exporter improvements Bastien
2012-08-05 20:02   ` Yann Hodique
2012-08-06  8:15   ` Bastien
2012-08-10  5:25 ` Christian Egli
2012-08-15 19:11 ` [PATCH v2 00/11] " Yann Hodique
2012-08-15 19:11   ` [PATCH 04/10] org-taskjuggler: task with end-only is also a milestone (deadline) Yann Hodique
2012-08-16  7:48   ` [PATCH v2 00/11] Takjuggler exporter improvements Bastien
2012-08-16 18:37     ` Yann Hodique
2012-08-19  7:27       ` Bastien
2012-08-16 19:01   ` [PATCH v3 00/11] Taskjuggler " Yann Hodique
2012-08-16 19:01     ` [PATCH v3 01/11] org-taskjuggler.el: Make task and resource properties customizable Yann Hodique
2012-08-16 19:02     ` [PATCH v3 02/11] org-taskjuggler.el: Properly install local variables at export time Yann Hodique
2012-08-16 19:02     ` [PATCH v3 03/11] org-taskjuggler.el: Make use of org properties Yann Hodique
2012-08-16 19:02     ` [PATCH v3 04/11] org-taskjuggler.el: Fix milestone definition Yann Hodique
2012-08-16 19:02     ` [PATCH v3 05/11] org-taskjuggler.el: Introduce a global header, for early macros Yann Hodique
2012-08-16 19:02     ` [PATCH v3 06/11] org-taskjuggler.el: Use project end date, if specified Yann Hodique
2012-08-16 19:02     ` [PATCH v3 07/11] org-taskjuggler.el: Make project umbrella task optional Yann Hodique
2012-08-16 19:02     ` [PATCH v3 08/11] org-taskjuggler.el: Disambiguate "headline", as it's a valid attribute Yann Hodique
2012-08-16 19:02     ` [PATCH v3 09/11] org-taskjuggler.el: Allow reports definition from within the org file Yann Hodique
2012-08-16 19:02     ` [PATCH v3 10/11] org-taskjuggler.el: Update doc to reflect latest changes Yann Hodique
2012-08-16 19:02     ` [PATCH v3 11/11] org-taskjuggler.el: Make taskjuggler compatible with org-publish Yann Hodique
2012-08-26  7:55     ` [PATCH v3 00/11] Taskjuggler exporter improvements Bastien
2012-09-25 13:53       ` Christian Egli
2012-08-15 19:11 ` [PATCH v2 01/11] org-taskjuggler: make task and resource properties customizable Yann Hodique
2012-08-15 19:11 ` [PATCH v2 02/11] org-taskjuggler: properly install local variables at export time Yann Hodique
2012-08-15 19:11 ` [PATCH v2 03/11] org-taskjuggler: make use of org properties Yann Hodique
2012-08-15 19:11 ` [PATCH v2 04/11] org-taskjuggler: fix milestone definition Yann Hodique
2012-08-15 19:11 ` [PATCH v2 05/11] org-taskjuggler: introduce a global header, for early macros Yann Hodique
2012-08-15 19:11 ` [PATCH v2 06/11] org-taskjuggler: use project end date, if specified Yann Hodique
2012-08-15 19:11 ` [PATCH v2 07/11] org-taskjuggler: make project umbrella task optional Yann Hodique
2012-08-15 19:11 ` [PATCH v2 08/11] org-taskjuggler: disambiguate "headline", as it's also a valid property Yann Hodique
2012-08-15 19:11 ` [PATCH v2 09/11] org-taskjuggler: allow reports definition from within the org file Yann Hodique
2012-08-15 19:11 ` [PATCH v2 10/11] org-taskjuggler: update doc to reflect latest changes Yann Hodique
2012-08-15 19:11 ` Yann Hodique [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1345057917-69300-13-git-send-email-yann.hodique@gmail.com \
    --to=yann.hodique@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --subject='Re: [PATCH v2 11/11] org-taskjuggler: make taskjuggler compatible with org-publish' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).