From mboxrd@z Thu Jan 1 00:00:00 1970 From: zwz Subject: Re: [babel] support plantuml Date: Thu, 26 Aug 2010 22:23:45 +0800 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from [140.186.70.92] (port=38798 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OodNM-0003pH-KC for emacs-orgmode@gnu.org; Thu, 26 Aug 2010 10:24:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OodNL-0004dr-Du for emacs-orgmode@gnu.org; Thu, 26 Aug 2010 10:24:20 -0400 Received: from lo.gmane.org ([80.91.229.12]:44346) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OodNJ-0004dN-W2 for emacs-orgmode@gnu.org; Thu, 26 Aug 2010 10:24:19 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OodNI-0006On-P4 for emacs-orgmode@gnu.org; Thu, 26 Aug 2010 16:24:16 +0200 Received: from 221.12.171.112 ([221.12.171.112]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 26 Aug 2010 16:24:16 +0200 Received: from zhangweize by 221.12.171.112 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 26 Aug 2010 16:24:16 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Mike Gauland writes: > Mike Gauland gmail.com> writes: > >> I can get an image if I evaluate the block manually (e.g., via 'C-c > C-c' with >> the cursor on the BEGIN block), but when I export the file the image > is >> invalid. > > I figured it out. I was getting extra carriage returns in the file. I've > fixed > them by setting "coding-system-for-write" to 'no-conversion within the > (let). > > --Mike > I also encountered the same problem. But it seems not work perfectly by letting "coding-system-for-write" be 'no-conversion. For example: In my "test.org" * test #+BEGIN_SRC plantuml :file test.png Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response #+END_SRC #+BEGIN_SRC plantuml :file test2.png Alice2 -> Bob: Authentication Request Bob --> Alice: Authentication Response #+END_SRC C-c C-c on the second src block does not create a right image. So here is a new version of "ob-plantuml.el", which utilizes the io redirection in shell directly. Hope that it addresses the problem. --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=ob-plantuml.el Content-Transfer-Encoding: quoted-printable ;;; ob-plantuml.el --- org-babel functions for plantuml evaluation ;; Author: Zhang Weize ;;; Commentary: ;; Org-Babel support for evaluating plantuml script. ;; ;; Inspired by Ian Yang's org-export-blocks-format-plantuml ;; http://www.emacswiki.org/emacs/org-export-blocks-format-plantuml.el ;;; Code: (require 'ob) (defvar org-babel-default-header-args:plantuml '((:results . "file") (:exports . "results")) "Default arguments for evaluating a plantuml source block.") (defun org-babel-expand-body:plantuml (body params &optional processed-para= ms) "Expand BODY according to PARAMS, return the expanded body." body) (defvar org-plantuml-jar-path) (defun org-babel-execute:plantuml (body params) "Execute a block of plantuml code with org-babel. This function is called by `org-babel-execute-src-block'." (let ((result-params (split-string (or (cdr (assoc :results params)) ""))) (out-file (cdr (assoc :file params))) (cmdline (cdr (assoc :cmdline params))) (in-file (make-temp-file "org-babel-plantuml"))) (unless (file-exists-p org-plantuml-jar-path) (error "Could not find plantuml.jar at %s" org-plantuml-jar-path)) (with-temp-file in-file (insert (concat "@startuml\n" body "\n@enduml")= )) (message (concat "java -jar " org-plantuml-jar-path " -p " cmdline " < " in-file " > " out-file)) (shell-command (concat "java -jar " (shell-quote-argument org-plantuml-= jar-path) " -p " cmdline " < " in-file " > " out-file)) ; The method below will produce error when exporting the buffer. ;; (with-temp-buffer ;; (call-process-shell-command ;; (concat "java -jar " org-plantuml-jar-path " -p " cmdline) ;; in-file ;; '(t nil)) ;; (write-region nil nil out-file)) out-file)) (defun org-babel-prep-session:plantuml (session params) "Return an error because plantuml does not support sessions." (error "Plantuml does not support sessions")) (provide 'ob-plantuml) ;;; ob-plantuml.el ends here --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--