From mboxrd@z Thu Jan 1 00:00:00 1970 From: zwz Subject: [babel] support plantuml Date: Wed, 25 Aug 2010 22:42:37 +0800 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from [140.186.70.92] (port=35251 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OoHMB-0003EW-GX for emacs-orgmode@gnu.org; Wed, 25 Aug 2010 10:53:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OoHCI-0003yj-Bk for emacs-orgmode@gnu.org; Wed, 25 Aug 2010 10:43:27 -0400 Received: from lo.gmane.org ([80.91.229.12]:32949) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OoHCI-0003yX-0q for emacs-orgmode@gnu.org; Wed, 25 Aug 2010 10:43:26 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OoHCD-0004iy-UV for emacs-orgmode@gnu.org; Wed, 25 Aug 2010 16:43:21 +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 ; Wed, 25 Aug 2010 16:43:21 +0200 Received: from zhangweize by 221.12.171.112 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 25 Aug 2010 16:43:21 +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 --=-=-= I came across Ian Yang's [[http://www.emacswiki.org/emacs/org-export-blocks-format-plantuml.el][org-export-blocks-format-plantuml]] a few days ago, which brought me in front of the great software [[http://plantuml.sourceforge.net/][Plantuml]]. It is an open-source tool in java that allows to quickly write: - sequence diagram, - use case diagram, - class diagram, - activity diagram, - component diagram, - state diagram - object diagram using a simple and intuitive language. Although Ian Yang's code has incorporated plantuml in org-mode by =#+BEGIN_UML= and =#+END_UML=, I think it should be a good idea to introduce the plantuml as a new language into org-babel. Here is the "ob-plantuml.el": --=-=-= 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 ;; Homepage: http://orgmode.org ;;; Commentary: ;; Org-Babel support for evaluating plantuml source code. ;; ;; Some code in ob-plantuml was adopted from ;; 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)) (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=gb2312 Content-Transfer-Encoding: 8bit I am not sure if it is qualified to be part of org-babel, so I just put it here first. In addition, I also wrote a new major mode ˇ°plantuml-mode.elˇ± which provides preliminary font-lock function for plantuml scripts, see http://zhangweize.wordpress.com/. --=-=-= 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 --=-=-=--