1. Install a Common Lisp implementation, or several of them
- SBCL for Windows with threads: https://github.com/akovalenko/sbcl-win32-threads/wiki
- CLISP is slow, and singlethreaded but makes relatively small binaries
- CCL is reportedly good?
2. Install Emacs. Official GNU Emacs Windows binaries should work: http://ftp.gnu.org/gnu/emacs/windows/
3. Create a directory where you will store your Lisp projects (you could use Quicklisp's default one but screw that, "c:/lisp" is better than "c:/users/<username>/quicklisp/local-projects")
4. Download Quicklisp from http://beta.quicklisp.org/quicklisp.lisp and put it into your Lisp directory.
5. Start up your Lisp and do (load "c:/lisp/quicklisp.lisp")
. Follow the instructions to install Quicklisp and add it to your Lisp's init file...
(quicklisp-quickstart:install)
(ql:add-to-init-file)
6. While we're at it, install SLIME from quicklisp.
(ql:quickload "quicklisp-slime-helper")
7. Open Emacs and do C-x C-f (Ctrl-x, followed by Ctrl-f) and type "~/.emacs" in the minibuffer. This should open your Emacs file. By default it resides in "c:/users/<username>/AppData/Roaming/", this being Emacs's HOME directory.
(add-to-list 'exec-path "C:/sbcl") ;; or wherever you installed SBCL or other Lisp
(load (expand-file-name "~/quicklisp/slime-helper.el"))
(setq inferior-lisp-program "sbcl") ;; or other Lisp
(slime-setup '(slime-fancy slime-asdf)) ;; and possibly other SLIME extensions
(add-hook 'slime-mode-hook
'(lambda ()
(set-variable lisp-indent-function 'common-lisp-indent-function)
(define-key slime-mode-map [tab] 'slime-indent-and-complete-symbol)
(define-key slime-mode-map (kbd "C-<tab>") 'slime-complete-symbol)))
Type C-x C-s to save file.
8. I already mentioned that Emacs's home dir is "c:/users/<username>/AppData/Roaming/" whereas Quicklisp infrastructure assumes "c:/users/<username>/" is the home dir. This is probably configurable on Quicklisp side, and definitely configurable on Emacs side (setting environment variable HOME to "c:/users/<username>/" might solve this issue), but I found that the easiest way to resolve this is to add a symlink for quicklisp's directory. Start Windows command line (Win-R then "cmd"), and do the following:
cd AppData\Roaming
mklink /J quicklisp ..\..\quicklisp
9. Find your Lisp's init file! It should be in "c:/users/<username>/". For SBCL it's .sbclrc, for CLISP it's .clisprc and so on. When you start Lisp from within Emacs, it would try to load it from Emacs home folder, so copy it there. It might in fact be useful to have two different startup files for "bare" Lisp and SLIME shell Lisp.
10. OK, now restart your Emacs and press M-x slime (Alt-x, then type "slime" in minibuffer and press Enter). If you set up everything correctly this should start up your Lisp and load Quicklisp too. Try doing something like
(ql:quickload "cl-ppcre")
11. The only thing left is to configure ASDF so that it could recursively load your own projects from "c:/lisp" or whatever directory you created earlier. Open file "~/.config/common-lisp/source-registry.conf.d/asdf.conf" in Emacs and put the following into it:
(:tree "c:/lisp/")
12. Stuff to do:
(ql:quickload :quickproject)
(quickproject:make-project "c:/lisp/my-test-project/" :name "my-test-project" :depends-on '(:cl-ppcre))
Define some functions in c:/lisp/my-test-project/my-test-project.lisp , you should be able to do (ql:quickload :my-test-project)
to load it and its dependencies. You should also be able to do (asdf:load-system :my-test-project)
or ",l <Enter> my-test-project <Enter>" in SLIME.
13. Optional things:
If you have 64-bit Windows, you need 64-bit OpenSSL .dll for this to work. Install "Win64 OpenSSL v1.0.1e" and "Visual C++ 2008 Redistributables (x64)" from http://slproweb.com/products/Win32OpenSSL.html and copy libssl32.dll to c:\Windows\System32
If (member :asdf3 *features*)
is nil, then you're probably not as bleeding edge as you think! Quicklisp only comes with ASDF2 and so does the Windows threaded fork of SBCL which I mentioned in the beginning. ASDF3, among other things, contains a rather useful library UIOP, which you might want to use if you ever deal with filesystems/pathnames/OS portability/inter-Lisp portability and so on. It also can make executable files out of your ASDF systems.
Anyway, the recommended way to upgrade listed in ASDF documentation doesn't seem to work ( (asdf:load-system "asdf)
doesn't load new version of ASDF if you already got an old one), so the sure way to make sure you have ASDF3 is to put new asdf.lisp somewhere and add
#-asdf3
(load "c:/lisp/asdf") ;; or wherever you put it
to .sbclrc
(todo)
Thank u 🆒