emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Yujie Wen <yjwen.ty@gmail.com>
To: "emacs-orgmode@gnu.org Mode" <emacs-orgmode@gnu.org>
Subject: [Patch] ob-ditaa.el for Cygwin
Date: Fri, 12 Jul 2013 13:59:31 +0800	[thread overview]
Message-ID: <CAHenMCFA3kaL3w-hUpy5cPU7Cmc+rSip4hN6Bo9QHPYTuGSZvg@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 512 bytes --]

Hi,

  ob-ditaa.el calls Java VM to generate pictures. Unfortunately, Cygwin
doesn't have native Java VM. In order to call the Windows native Java VM
properly, all Cygwin paths pointing to ditaa.jar, the temporary input file
and the output picture file must be changed to Windows native paths, for
example, /home/yujie/ditaa.jar to d:/cygwin/home/yujie/ditaa.jar.

  Here is a patch that detect whether current Emacs is of Cygwin version
and, if so, add `cygpath -w ` to wrap all related pathes.

Regards,
Yujie

[-- Attachment #1.2: Type: text/html, Size: 609 bytes --]

[-- Attachment #2: cygwin.patch --]
[-- Type: application/octet-stream, Size: 1570 bytes --]

diff --git a/lisp/ob-ditaa.el b/lisp/ob-ditaa.el
index d3d76e5..63967de 100644
--- a/lisp/ob-ditaa.el
+++ b/lisp/ob-ditaa.el
@@ -86,13 +86,29 @@ This function is called by `org-babel-execute-src-block'."
 	 (java (cdr (assoc :java params)))
 	 (in-file (org-babel-temp-file "ditaa-"))
 	 (eps (cdr (assoc :eps params)))
+	 (jar-file-name (shell-quote-argument
+			 (expand-file-name
+			  (if eps org-ditaa-eps-jar-path org-ditaa-jar-path))))
+	 (emacs-p (string-match "cygwin" (emacs-version)))
+	 (jar-file-name-wrapped
+	  (if emacs-p
+	      ;; Cygwin doesn't have Jave, have to use Windows native Java.
+	      ;; So Cygwin paths must be converted to Windows paths.
+	      (format "`cygpath -w %s`" jar-file-name)
+	    jar-file-name))
+	 (in-file-wrapped
+	  (if emacs-p
+	      (format "`cygpath -w %s`" (org-babel-process-file-name in-file))
+	    (org-babel-process-file-name in-file)))
+	 (out-file-wrapped
+	  (if emacs-p
+	      (format "`cygpath -w %s`" (org-babel-process-file-name out-file))
+	    (org-babel-process-file-name out-file)))
 	 (cmd (concat "java " java " " org-ditaa-jar-option " "
-		      (shell-quote-argument
-		       (expand-file-name
-			(if eps org-ditaa-eps-jar-path org-ditaa-jar-path)))
+		      jar-file-name-wrapped
 		      " " cmdline
-		      " " (org-babel-process-file-name in-file)
-		      " " (org-babel-process-file-name out-file)))
+		      " " in-file-wrapped
+		      " " out-file-wrapped))
 	 (pdf-cmd (when (and (or (string= (file-name-extension out-file) "pdf")
 				 (cdr (assoc :pdf params))))
 		    (concat

             reply	other threads:[~2013-07-12  5:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-12  5:59 Yujie Wen [this message]
2013-07-12  6:05 ` [Patch] ob-ditaa.el for Cygwin Jambunathan K
     [not found]   ` <CAHenMCHGzkb9GPuoS2xYifFBohzO2r7hvxp5yztySsL8penbJw@mail.gmail.com>
     [not found]     ` <877ggw2szv.fsf@gmail.com>
2013-07-16  1:23       ` Yujie Wen
2013-07-16  5:34         ` Achim Gratz
2013-07-16 13:34           ` Yujie Wen
2013-07-17 14:21           ` Eric Schulte

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=CAHenMCFA3kaL3w-hUpy5cPU7Cmc+rSip4hN6Bo9QHPYTuGSZvg@mail.gmail.com \
    --to=yjwen.ty@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public 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).