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
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)
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.
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
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."
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"
59 (with-temp-file in-file
(insert body
))
61 ((lambda (raw) ;; " | grep -v batch | grep -v 'replaced' | sed '/^$/d' "
65 (mapcar (lambda (line)
66 (unless (or (string-match "batch" line
)
67 (string-match "^rat: replaced .*$" 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"))
78 ;; arch-tag: d86c97ac-7eab-4349-8d8b-302dd09779a8
80 ;;; org-babel-maxima.el ends here