emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BABEL,PATCH] Add graphical output to ob-octave
@ 2011-12-17  9:01 Litvinov Sergey
  2011-12-17 16:02 ` Eric Schulte
  0 siblings, 1 reply; 2+ messages in thread
From: Litvinov Sergey @ 2011-12-17  9:01 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 156 bytes --]

I propose a patch to make the following example work in ob-octave.
#+begin_src octave :results graphics :file chart.png
sombrero; % make a figure
#+end_src

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-octave.el-Add-graphical-output.patch --]
[-- Type: text/x-diff, Size: 2746 bytes --]

From f193df8b1b7d1330a0dde89907a607051f632775 Mon Sep 17 00:00:00 2001
From: Litvinov Sergey <slitvinov@gmail.com>
Date: Fri, 16 Dec 2011 20:12:39 +0100
Subject: [PATCH] ob-octave.el: Add graphical output

    * lisp/ob-octave.el: add graphical output to png file

    * testing/examples/ob-octave-test.org: add a test for graphical
      output, and a test for session
---
 lisp/ob-octave.el                   |   30 +++++++++++++++++++++++-------
 testing/examples/ob-octave-test.org |   10 ++++++++++
 2 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/lisp/ob-octave.el b/lisp/ob-octave.el
index f840739..796a5c7 100644
--- a/lisp/ob-octave.el
+++ b/lisp/ob-octave.el
@@ -86,13 +86,24 @@ end")
 	  (org-babel-expand-body:generic
 	   body params (org-babel-variable-assignments:octave params)))
 	 (result (org-babel-octave-evaluate
-		  session full-body result-type matlabp)))
-    (org-babel-reassemble-table
-     result
-     (org-babel-pick-name
-      (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
-     (org-babel-pick-name
-      (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))))
+		  session
+		  (if (org-babel-octave-graphical-output-file params)
+		      (mapconcat 'identity
+				 (list
+				  "set (0, \"defaultfigurevisible\", \"off\");"
+				  full-body
+				  (format "print -dpng %s" (org-babel-octave-graphical-output-file params)))
+				 "\n")
+		    full-body)
+		  result-type matlabp)))
+    (if (org-babel-octave-graphical-output-file params)
+	nil
+      (org-babel-reassemble-table
+       result
+       (org-babel-pick-name
+	(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
+       (org-babel-pick-name
+	(cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))))
 
 (defun org-babel-prep-session:matlab (session params)
   "Prepare SESSION according to PARAMS."
@@ -259,6 +270,11 @@ This removes initial blank and comment lines and then calls
       (match-string 1 string)
     string))
 
+(defun org-babel-octave-graphical-output-file (params)
+  "Name of file to which maxima should send graphical output."
+  (and (member "graphics" (cdr (assq :result-params params)))
+       (cdr (assq :file params))))
+
 (provide 'ob-octave)
 
 
diff --git a/testing/examples/ob-octave-test.org b/testing/examples/ob-octave-test.org
index 97d9b00..9839d63 100644
--- a/testing/examples/ob-octave-test.org
+++ b/testing/examples/ob-octave-test.org
@@ -43,3 +43,13 @@ Input elisp nil
 #+begin_src octave :exports results :results silent :var s='nil
 ans = s
 #+end_src
+
+
+* Graphical tests
+#+begin_src octave :results graphics :file chart.png
+sombrero;
+#+end_src
+
+#+begin_src octave :session
+sombrero;
+#+end_src
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-12-17 16:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-17  9:01 [BABEL,PATCH] Add graphical output to ob-octave Litvinov Sergey
2011-12-17 16:02 ` Eric Schulte

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).