Fix typo in function name
[org-mode.git] / lisp / ob-maxima.el
blob06f6793059d7915dc9c72178ffb84f2b3823d24d
1 ;;; org-babel-maxima.el --- org-babel functions for maxima evaluation
3 ;; Copyright (c) 2009, 2010, 2011 Eric S Fraga, Eric Schulte
5 ;; Author: Eric S Fraga, Eric Schulte
6 ;; Keywords: literate programming, reproducible research, maxima
7 ;; Homepage: http://orgmode.org
8 ;; Version: 0.01
10 ;;; License:
12 ;; This program is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 3, or (at your option)
15 ;; any later version.
17 ;; This program is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
27 ;;; Commentary:
29 ;; Org-Babel support for evaluating maxima entries.
31 ;; This differs from most standard languages in that
33 ;; 1) there is no such thing as a "session" in maxima
35 ;; 2) we are generally only going to return output from maxima
37 ;; 3) we are adding the "cmdline" header argument
39 ;; 4) there are no variables
41 ;;; Code:
42 (require 'ob)
44 (defvar org-babel-default-header-args:maxima '())
46 (defun org-babel-maxima-expand (body params)
47 "Expand a block of Maxima code according to its header arguments."
48 body)
50 (defun org-babel-execute:maxima (body params)
51 "Execute a block of Maxima entries with org-babel. This function is
52 called by `org-babel-execute-src-block'."
53 (message "executing Maxima source code block")
54 (let* ((result-params (split-string (or (cdr (assoc :results params)) "")))
55 (cmdline (cdr (assoc :cmdline params)))
56 (in-file (org-babel-temp-file "maxima-"))
57 (cmd (format "maxima --very-quiet -r 'batchload(%S)$' %s"
58 in-file cmdline)))
59 (with-temp-file in-file (insert body))
60 (message cmd)
61 ((lambda (raw) ;; " | grep -v batch | grep -v 'replaced' | sed '/^$/d' "
62 (mapconcat
63 #'identity
64 (delq nil
65 (mapcar (lambda (line)
66 (unless (or (string-match "batch" line)
67 (string-match "^rat: replaced .*$" line)
68 (= 0 (length line)))
69 line))
70 (split-string raw "[\r\n]"))) "\n"))
71 (org-babel-eval cmd ""))))
73 (defun org-babel-prep-session:maxima (session params)
74 (error "Maxima does not support sessions"))
76 (provide 'ob-maxima)
78 ;; arch-tag: d86c97ac-7eab-4349-8d8b-302dd09779a8
80 ;;; org-babel-maxima.el ends here