From 2538e687dae7dacab6d17f9fce4db7d16474fbaf Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Mon, 5 Jul 2010 19:03:25 -0700 Subject: [PATCH] babel: updating ob-dot.el and ob-mscgen.el to use ob-eval --- lisp/ob-dot.el | 7 ++++--- lisp/ob-mscgen.el | 28 +++++++++++++--------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/lisp/ob-dot.el b/lisp/ob-dot.el index e22defd8e..a42f451c9 100644 --- a/lisp/ob-dot.el +++ b/lisp/ob-dot.el @@ -40,8 +40,10 @@ ;;; Code: (require 'ob) +(require 'ob-eval) -(defvar org-babel-default-header-args:dot '((:results . "file") (:exports . "results")) +(defvar org-babel-default-header-args:dot + '((:results . "file") (:exports . "results")) "Default arguments to use when evaluating a dot source block.") (defun org-babel-expand-body:dot (body params &optional processed-params) @@ -57,8 +59,7 @@ called by `org-babel-execute-src-block'." (cmd (or (cdr (assoc :cmd params)) "dot")) (in-file (make-temp-file "org-babel-dot"))) (with-temp-file in-file (insert body)) - (message (concat cmd " " in-file " " cmdline " -o " out-file)) - (shell-command (concat cmd " " in-file " " cmdline " -o " out-file)) + (org-babel-eval (concat cmd " " in-file " " cmdline " -o " out-file) "") out-file)) (defun org-babel-prep-session:dot (session params) diff --git a/lisp/ob-mscgen.el b/lisp/ob-mscgen.el index 256448b08..5c9f3e595 100644 --- a/lisp/ob-mscgen.el +++ b/lisp/ob-mscgen.el @@ -28,7 +28,8 @@ ;; sequence charts. The mscgen utility is used for processing the ;; sequence definition, and must therefore be installed in the system. ;; -;; Mscgen is available and documented at http://www.mcternan.me.uk/mscgen/index.html +;; Mscgen is available and documented at +;; http://www.mcternan.me.uk/mscgen/index.html ;; ;; This code is directly inspired by Eric Schulte's ob-dot.el ;; @@ -55,6 +56,7 @@ ;;; Code: (require 'ob) +(require 'ob-eval) (defvar org-babel-default-header-args:mscgen '((:results . "file") (:exports . "results")) @@ -64,22 +66,18 @@ "Expand BODY according to PARAMS, return the expanded body." body) (defun org-babel-execute:mscgen (body params) - "Execute a block of Mscgen code with org-babel. This function is -called by `org-babel-execute-src-block'. -Default filetype is png. Modify by setting :filetype parameter to mscgen supported formats." + "Execute a block of Mscgen code with org-babel. This function +is called by `org-babel-execute-src-block'. Default filetype is +png. Modify by setting :filetype parameter to mscgen supported +formats." (message "executing Mscgen source code block") (let* ((out-file (or (cdr (assoc :file params)) "output.png" )) - exit-code - (filetype (or (cdr (assoc :filetype params)) "png" )) - (stderr - (with-temp-buffer - (insert body) - (setq exit-code (org-babel-shell-command-on-region - (point-min) (point-max) (concat "mscgen -T " filetype " -o " out-file) - nil 'replace (current-buffer))) - (buffer-string)))) - (unless (cdr (assoc :file params)) (setq stderr (concat stderr "\nERROR: no output file specified. Add \":file some_name.png\" to the src header" )) (error stderr)) - (if (> exit-code 0) (org-babel-error-notify exit-code stderr)) + (filetype (or (cdr (assoc :filetype params)) "png" ))) + (unless (cdr (assoc :file params)) + (error (concat + "\nERROR: no output file specified. " + "Add \":file some_name.png\" to the src header"))) + (org-babel-eval (concat "mscgen -T " filetype " -o " out-file) body) out-file)) (defun org-babel-prep-session:mscgen (session params) -- 2.11.4.GIT