Avoid XHTML strict problems by not enclosing special blocks in paragraph tags
[org-mode.git] / lisp / ob-maxima.el
blob085609c10ebd765ca90f1f50d788412e1fc60836
1 ;;; ob-maxima.el --- org-babel functions for maxima evaluation
3 ;; Copyright (C) 2009-2011 Free Software Foundation, Inc.
5 ;; Author: Eric S Fraga
6 ;; Eric Schulte
7 ;; Keywords: literate programming, reproducible research, maxima
8 ;; Homepage: http://orgmode.org
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs 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 of the License, or
15 ;; (at your option) any later version.
17 ;; GNU Emacs 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. If not, see <http://www.gnu.org/licenses/>.
25 ;;; Commentary:
27 ;; Org-Babel support for evaluating maxima entries.
29 ;; This differs from most standard languages in that
31 ;; 1) there is no such thing as a "session" in maxima
33 ;; 2) we are generally only going to return output from maxima
35 ;; 3) we are adding the "cmdline" header argument
37 ;; 4) there are no variables
39 ;;; Code:
40 (require 'ob)
42 (defvar org-babel-default-header-args:maxima '())
44 (defun org-babel-maxima-expand (body params)
45 "Expand a block of Maxima code according to its header arguments."
46 body)
48 (defun org-babel-execute:maxima (body params)
49 "Execute a block of Maxima entries with org-babel. This function is
50 called by `org-babel-execute-src-block'."
51 (message "executing Maxima source code block")
52 (let* ((result-params (split-string (or (cdr (assoc :results params)) "")))
53 (cmdline (cdr (assoc :cmdline params)))
54 (in-file (org-babel-temp-file "maxima-"))
55 (cmd (format "maxima --very-quiet -r 'batchload(%S)$' %s"
56 in-file cmdline)))
57 (with-temp-file in-file (insert body))
58 (message cmd)
59 ((lambda (raw) ;; " | grep -v batch | grep -v 'replaced' | sed '/^$/d' "
60 (mapconcat
61 #'identity
62 (delq nil
63 (mapcar (lambda (line)
64 (unless (or (string-match "batch" line)
65 (string-match "^rat: replaced .*$" line)
66 (= 0 (length line)))
67 line))
68 (split-string raw "[\r\n]"))) "\n"))
69 (org-babel-eval cmd ""))))
71 (defun org-babel-prep-session:maxima (session params)
72 (error "Maxima does not support sessions"))
74 (provide 'ob-maxima)
78 ;;; ob-maxima.el ends here