Great news: ob-plantuml has been accepted as a part of org-babel in its git repository.
Here is the new version of it:
;;; 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-params) "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
Hi,
Great job!
Anyway, I’ve noticed that in your source code, you have hardcoded PlantUML keywords.
This may be an issue, because PlantUML language change quite often.
To turn arround this, I’ve added an option “-language” in the command line:
java -jar plantuml.jar -language
This prints on the standard output a list of keywords/type/color. So instead of hardcoding
those data, you can retrieve them dynamically. So when PlantUML.jar will be updated,
new keywords will be automatically recognized in emacs.
Do you thing it’s useful ?
Regards,
Yes, it is a helpful tip.
I have tested the new plantuml.jar and the option -language. It is really nice.
Some time later I will update the plantuml-mode accordingly.
On Sat, Sep 11, 2010 at 7:44 PM, comment-reply@wordpress.com wrote:
> New comment on your post “A new version of ob-plantuml” > Author : Arnaud (IP: 85.115.60.180 , webdefence.cluster-d.websense.net) > E-mail : plantuml@gmail.com > URL : http://plantuml.sourceforge.net/ > Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=85.115.60.180