Running Maxima with Slime



Recently i have seen here some messages asking how to run maxima with slime,
and some answers. Also i have searched the web and found various recipes. None
worked "out of the box" for me. After having read a little inside the slime
distribution i have found a very simple solution which works perfectly for me.
I want to share it here for the benefit of newcomers like me who are not
versed in the arcanes of lisp .

Context: i run this on maxima-5.25.1 compiled with the latest sbcl available
for Mac OS X. I have recompiled maxima instead of using the precompiled one
available because i encountered asdl problems with that one, and once these
cured, i got problems with modules compiled with different versions of sbcl.
Recompiling maxima everything works OK except that maxima doesn't find
gnuplot. This is solved by a symbolic link /usr/local/bin/gnuplot
-> /Applications/Gnuplot.app/Contents/Resources/bin/gnuplot. On the emacs side
i am using the precompiled aquamacs and the packaged slime coming with it.
On the mac it works wonderfully, in my opinion.


So the trick, as explained in the web is to run slime inside maxima (not the
other way around) and to load it using asdl. This is done by loading in maxima
the following file (of course one needs to adapt the place where slime
resides, and one can choose the port number at will):

lilas% cat .maxima/startswank.lisp
(pushnew "/Library/Application Support/Aquamacs Emacs/SLIME/"
asdf:*central-registry*)
;;(require :asdf)
(require :swank)
(swank:create-server :port 56789 :dont-close t :coding-system
"iso-latin-1-unix")

Here (required :asdf) is necessary to run that under sbcl, but not under
maxima. This works as follows:

lilas% maxima
(%i1) load(startswank);

;; loading #P"/Users/michel/.slime/fasl/2011-09-28/sbcl-1.0.51.0-a546163-darwi
n-x86/swank-backend.fasl"
;; loading #P"/Users/michel/.slime/fasl/2011-09-28/sbcl-1.0.51.0-a546163-darwi
n-x86/swank-source-path-parser.fasl"
;; loading #P"/Users/michel/.slime/fasl/2011-09-28/sbcl-1.0.51.0-a546163-darwi
n-x86/swank-source-file-cache.fasl"
;; loading #P"/Users/michel/.slime/fasl/2011-09-28/sbcl-1.0.51.0-a546163-darwi
n-x86/swank-sbcl.fasl"
;; loading #P"/Users/michel/.slime/fasl/2011-09-28/sbcl-1.0.51.0-a546163-darwi
n-x86/swank-gray.fasl"
;; loading #P"/Users/michel/.slime/fasl/2011-09-28/sbcl-1.0.51.0-a546163-darwi
n-x86/swank-match.fasl"
;; loading #P"/Users/michel/.slime/fasl/2011-09-28/sbcl-1.0.51.0-a546163-darwi
n-x86/swank-rpc.fasl"
;; loading #P"/Users/michel/.slime/fasl/2011-09-28/sbcl-1.0.51.0-a546163-darwi
n-x86/swank.fasl"
WARNING: These Swank interfaces are unimplemented:
 (DISASSEMBLE-FRAME INTERRUPT-THREAD RECEIVE-IF SEND SLDB-BREAK-AT-START
  SLDB-BREAK-ON-RETURN SPAWN)
;; Swank started at port: 56789.
(%o1)                /Users/michel/.maxima/startswank.lisp


Finally under emacs, (configured to recognize slime, of course), one runs:
M-x slime-connect
and gets:
Host: 127.0.0.1
Port: 56789
Which produces the slime prompt:
; SLIME 2011-09-28
MAXIMA>

At the end one has two windows, one where one can type maxima code and get
maxima results, the other where one can type lisp code, and which gets the
debugging messages, which is extremely nice because slime has a powerful
inspector.

Note: this doesn't work when maxima is run from wxmaxima, for reasons i don't
know, the slime freezes. But one can run maxima under emacs, by
M-x maxima




-- 
Michel Talon