From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric S Fraga Subject: Re: [babel] maxima support? Date: Thu, 24 Feb 2011 10:25:06 +0000 Message-ID: <87bp21ohkt.fsf@pinto.chemeng.ucl.ac.uk> References: <5rbp23p04b.fsf@kana.aer.mw.tum.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from [140.186.70.92] (port=37438 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PsYNp-0004tp-Qs for emacs-orgmode@gnu.org; Thu, 24 Feb 2011 05:25:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PsYNo-0001IV-HG for emacs-orgmode@gnu.org; Thu, 24 Feb 2011 05:25:17 -0500 Received: from vscani-e.ucl.ac.uk ([144.82.108.33]:38051) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PsYNo-0001I0-Cr for emacs-orgmode@gnu.org; Thu, 24 Feb 2011 05:25:16 -0500 In-Reply-To: <5rbp23p04b.fsf@kana.aer.mw.tum.de> (Litvinov Sergey's message of "Wed, 23 Feb 2011 10:32:20 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Litvinov Sergey Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Litvinov Sergey writes: > I have not found (i)maxima on this page. > http://orgmode.org/worg/org-contrib/babel/languages.html > (Babel: Languages) > > Has someone implemented it? I have implemented a very basic interface (attached). Example: #+begin-src org * maxima test *** simple test #+begin_src maxima programmode: false; eq: x**2-1 = 0; solution: solve(eq, x); print(solution); #+end_src #+results: : [x = - 1, x = 1] #+end_src However, please note that this is rather linux (maybe Unix) specific in that it post-processes the output of maxima using a sequence of shell commands to get rid of unnecessary (to my mind) output. Maxima is a bit verbose... --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=ob-maxima.el Content-Transfer-Encoding: quoted-printable Content-Description: org babel maxima interface ;;; org-babel-maxima.el --- org-babel functions for maxima evaluation ;; Copyright (c) 2009 Eric S Fraga ;; based on code by ;; Copyright (C) 2009 Eric Schulte ;; Author: Eric Schulte ;; Keywords: literate programming, reproducible research ;; Homepage: http://orgmode.org ;; Version: 0.01 ;;; License: ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;;; Commentary: ;; Org-Babel support for evaluating maxima entries. ;; ;; This differs from most standard languages in that ;; ;; 1) there is no such thing as a "session" in maxima ;; ;; 2) we are generally only going to return output from the leger program ;; ;; 3) we are adding the "cmdline" header argument ;; ;; 4) there are no variables ;;; Code: ;; (require 'org-babel) ;;(org-babel-add-interpreter "maxima") ;;(add-to-list 'org-babel-tangle-langs '("maxima" "maxima")) (defvar org-babel-default-header-args:maxima '((:results . "output")) "Default arguments to use when evaluating a maxima source block.") (defun org-babel-execute:maxima (body params) "Execute a block of Maxima entries with org-babel. This function is called by `org-babel-execute-src-block'." (message "executing Maxima source code block") (let ((result-params (split-string (or (cdr (assoc :results params)) ""))) (cmdline (cdr (assoc :cmdline params))) (in-file (make-temp-file "org-babel-maxima")) (out-file (make-temp-file "org-babel-maxima-output")) ) (with-temp-file in-file (insert body)) (setq maximacommand (concat "maxima --very-quiet -r 'batchload(\"" in-f= ile "\")$'" cmdline " | grep -v batch | grep -v 'replaced' | sed '/^$/d' " = " > " out-file)) (message maximacommand) (with-output-to-string (shell-command maximacommand)) (with-temp-buffer (insert-file-contents out-file) (buffer-string)) )) (defun org-babel-prep-session:maxima (session params) (error "Maxima does not support sessions")) (provide 'ob-maxima) ;;; org-babel-ledger.el ends here --=-=-= Content-Type: text/plain -- : Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1 : using Org-mode version 7.4 (release_7.4.529.gb23d) --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--