From: Litvinov Sergey <slitvinov@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [BABEL,PATCH] Add graphical output to ob-octave
Date: Sat, 17 Dec 2011 10:01:52 +0100 [thread overview]
Message-ID: <87sjkjlgfz.fsf@gmail.com> (raw)
[-- 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
next reply other threads:[~2011-12-17 9:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-17 9:01 Litvinov Sergey [this message]
2011-12-17 16:02 ` [BABEL,PATCH] Add graphical output to ob-octave Eric Schulte
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sjkjlgfz.fsf@gmail.com \
--to=slitvinov@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.