|
|||||||||||||
|
|
|
|
|
|
|
|
|
||||||
|
|
|||||||||||||
![]() ![]() ![]() ![]() ![]() ![]() |
Using SLIME with Allegro Common Lisp
What is SLIME?SLIME stands for the Superior Lisp Interaction Mode for Emacs. It is a development environment for writing Lisp applications that is compatible with most available Lisp implementations. It is favorable for developers writing code to multiple Lisp implementations as it provides a similar development experience regardless of the Lisp being used. There is a SLIME home page as well as a SLIME CLiki if you want to read more about the interface and the features it provides. Download SLIMEThere are three easy ways in which to download and install SLIME. NOTE: the instructions below assume you are running Lisp and Emacs on the same machine. You should visit the SLIME websites referenced above if you wish to set up a different configuration.
Configuring SLIMESLIME consists of two parts, a body of code which runs within Emacs (SLIME), and the SWANK server which runs in the Lisp. SLIME makes use of the inferior-lisp mode in emacs. On unix-like systems, this poses no problem for use with Allegro CL, but under windows, special configuration is required. This code will make SLIME available whenever you start up emacs. The call to slime-setup includes a number of contrib modules that you may find useful when using slime. slime-fancy actually causes a number of contrib modules to be loaded, and slime-banner makes a nice animation at startup. See the contrib/ subdirectory of your SLIME checkout to see what else is available. Interfacing to Emacs on UnixOn Unix, add the following to your .emacs file. The sample code below assumes SLIME is located in /usr/local/slime. ;; update this path to the correct location. (add-to-list 'load-path "/usr/local/slime") (require 'slime-autoloads) (eval-after-load "slime" '(progn (add-to-list 'load-path "/usr/local/slime/contrib") (slime-setup '(slime-fancy slime-banner)) (setq slime-complete-symbol*-fancy t) (setq slime-complete-symbol-function 'slime-fuzzy-complete-symbol))) ;; Optionally, specify the Lisp program you are using. Default is "lisp" ;; If the Allegro directory is not in your PATH environment variable ;; this should be a fully qualified path. ;; choose one of the below based on Express or non-Express usage ;; (setq inferior-lisp-program "alisp") (setq inferior-lisp-program "allegro-express") Interfacing to Emacs on WindowsInferior-lisp mode on Windows expects a win32 console application, which Allegro is not. There is build.exe and buildi.exe, but these are not recommended for development use. As such, it is necessary to construct a different way of starting Lisp and instructing the SWANK server on which port to listen. The sample code below assumes slime is installed in c:/cygwin/usr/local/slime. First, we create a file that Lisp will load at startup. It will contain code to start the swank server at a port that will be specified by a command-line argument "-p". A good place to save this file is in your home directory. For purposes of this example, we'll assume the segment below is saved to "c:/.slime.lisp"
(eval-when (:compile-toplevel :load-toplevel :execute)
(require :asdf))
(push "c:/cygwin/usr/local/slime/" asdf:*central-registry*)
(asdf:oos 'asdf:load-op :swank)
(swank-loader::init)
(sys:with-command-line-arguments (("p" :short port :required)
("ef" :long ef :required))
(restvar)
(swank::create-server :port (parse-integer port :junk-allowed nil)
:style :spawn
:dont-close t
:coding-system (or ef "latin-1")))
Add to your .emacs file: The code below defines the variables *slime-lisp* and *slime-port* which allows you to specify which Lisp to use and what port the swank server should listen on. They are easily changed, say, if you need to switch between mlisp and alisp, for example. It refers to a file that can be put anywhere. For this example it is assumed to be saved to "c:/.slime.lisp" (push "c:/cygwin/usr/local/slime/" load-path) (require 'slime-autoloads) (require 'slime) (slime-setup '(slime-fancy slime-banner)) (global-set-key "\C-cs" 'slime-selector) (setq slime-complete-symbol*-fancy t) (setq slime-complete-symbol-function 'slime-fuzzy-complete-symbol) (setq slime-multiprocessing t) ;; choose one of the below based on Express or non-Express usage ;; (setq *slime-lisp* "alisp.exe") (setq *slime-lisp* "allegro-express.exe") (setq *slime-port* 4006) (defun slime () (print "this is my slime") (interactive) (shell-command (format "%s +B +cm -L c:/cygwin/home/patchmgr/.slime.lisp -- -p %s --ef %s &" *slime-lisp* *slime-port* slime-net-coding-system)) (delete-other-windows) (while (not (ignore-errors (slime-connect "localhost" *slime-port*))) (sleep-for 0.2))) The code above actually redefines the default command for starting slime. The prevalant method used by the various solutions found on the net define a new keybinding to start Lisp on windows. The example below binds F5 to the function used to start SLIME. (global-set-key [(f5)] '(lambda () (interactive) (shell-command (format "%s +B +cm -L c:/cygwin/home/patchmgr/.slime.lisp -- -p %s --ef %s &" *slime-lisp* *slime-port* slime-net-coding-system)) (delete-other-windows) (while (not (ignore-errors (slime-connect "localhost" *slime-port*))) (sleep-for 0.2)))) Use this instead if you don't want to redefine the default slime command. Running SLIMEIf your .emacs has been modified with the above code, then you are ready to go. Simply start emacs and SLIME is ready to be used. Make sure *slime-lisp* is bound to the Lisp you wish to use, and *slime-port* is set to the port you want to use, then simply enter 'M-x slime' (or other keybinding, such as F5) within emacs and you should be connected to Lisp. For instructions on using SLIME, we recommend visiting the SLIME homepage as well as the SLIME CLiki. There are many great links on each. SupportAs we stated above, SLIME is not a product of Franz Inc. If you have problems you feel are specific only to Allegro CL, then feel free to contact us, otherwise you should contact the authors of SLIME. [WinZip problems] If trouble is encountered directly opening tarballs using winzip, try saving the tarball to disk first, then opening the saved file using winzip. [General] While this page makes reference to asdf, asdf-install, and slime, note that these are not Franz Products. Any problems installing or using these pieces of software should be directed to the appropriate community. Allegro specific errors related to these packages can be addressed via these entities.
© 2008 Franz Inc - Privacy Statement |