How to install Common Lisp and SLIME on MS Windows (2024)

A bit of diversion first. Let’s check the four must features of Lisp editors:

  1. indentation
  2. selecting a form
  3. clipboard management
  4. inserting the closing paren automatically for you.

You indent your Common Lisp code using TAB or C-M-\ the same as usual. Selecting forms can be done by pressing C-M-SPC multiple times (after maybe moving up using C-M-u multiple times), again the same as you already do with Emacs Lisp code. For clipboard management, you are already either using Emacs’s kill ring feature or an external clipboard manager. Now the fourth thing: automatic insertion of a closing parenthesis upon your insertion of an open parenthesis. You are probably already using something for that, ParEdit or SmartParens or AutoPair or electric pair mode. If not, time to choose. I have an article on how to install AutoPair. AutoPair is stable and is a team player. ParEdit is also stable, is only for Lisp modes, and it bans you from making unmatched parens, and that’s a good thing, but some may not like that. SmartParens and electric pair mode are the new kids. If you want me to choose one for you, I choose ParEdit if you can live with three keys <C-left>, <C-right>, <C-backspace> doing odd things, or if you know how to unbind those keys. End of diversion.

The key C-M-i is bound to slime-complete-symbol which is for completion of function names and so on. That is again just like when you are editing Emacs Lisp code.

Now try writing the following Common Lisp code but this time using C-M-i to help you complete dolist and print (pretend that you forgot the spelling for dolist)

(dolist (num (list 1 3 5 7 10 1 1 1 1 1)) (if (evenp num) (progn (print "found an even number. gonna return it") (return num)) (print num)))

Now evaluate that using C-M-x. The eval result 10 will be shown. Where’s the output from print? The output is in the *inferior-lisp* buffer. You have to switch to it to see the output. OK, this one was a bit different from evaluating Emacs Lisp code involving print, but even in Emacs Lisp buffers, when you evaluate a form that prints a long output, you switch to the *Messages* buffer to see it. If you don’t like switching to the *inferior-lisp* buffer, you may want to try these commands: slime-pprint-eval-last-expression and slime-pprint-eval-region.

You might have noticed something happening in the echo area when you were writing the dolist form. That’s the command slime-space (bound to SPC) showing argument lists of Common Lisp functions for you. Just like the ElDoc minor mode that you probably use with Emacs Lisp buffers. This feature only starts working after SLIME starts a Lisp connection, but you know that is guaranteed to happen when you evaluate a form or use C-M-i to complete a function name.

Try evaluating the following Common Lisp code:

(/ 1 0)

Just as you expected, an error is signaled and you are now in debugger. How do you get out then? How to quit this debugger? You should see a new submenu in the menu bar: SLDB. That stands for SLime DeBugger mode. From that submenu, you can find a way to quit the debugger. Or if you have time, you can press C-h m to start learning how to use SLDB.

How to install Common Lisp and SLIME on MS Windows (2024)
Top Articles
Latest Posts
Article information

Author: Dong Thiel

Last Updated:

Views: 6190

Rating: 4.9 / 5 (79 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Dong Thiel

Birthday: 2001-07-14

Address: 2865 Kasha Unions, West Corrinne, AK 05708-1071

Phone: +3512198379449

Job: Design Planner

Hobby: Graffiti, Foreign language learning, Gambling, Metalworking, Rowing, Sculling, Sewing

Introduction: My name is Dong Thiel, I am a brainy, happy, tasty, lively, splendid, talented, cooperative person who loves writing and wants to share my knowledge and understanding with you.