Testing out Lisp in Emacs
Set up development environment in Emacs
- Emacs - The default editor for Lisp development and is written in Lisp itself including the configuration file. Install Emacs on Ubuntu is easy with
sudo apt install emacsand for Windows you need to manually download the package for installation. It works on WSL too but only has the terminal version of Emacs. - SBCL - An implementation of Common Lisp by default in many editors and applications. Install SBCL with
sudo apt install sbclfor Ubuntu. - Slime - An extension of the Emacs editor. The installation guide can be found here https://github.com/slime/slime
- Quicklisp - Some commonly used libraries and utility functions for the current Lisp implementation like SBCL.
Basic usage of Emacs
Open a file
C-x C-fto find the file andC-x sto save the changesC-x zto suspend the editor and type%emacsto bring it back to the front.C-x C-cto permanently shut down the editor.M-x slimeto open the Slime editorC-x 2orC-x 3to split the window vertically or horizontally andC-x oto switch between panes.C-c C-cto compile the program in SlimeC-fMove forward a characterC-bMove backward a characterM-fMove forward a wordM-bMove backward a wordC-nMove to next lineC-pMove to previous lineC-aMove to beginning of lineC-eMove to end of lineM-aMove back to beginning of sentenceM-eMove forward to end of sentenceM-wto copy andC-yto paste
Switch back to Vim but still with Emacs enabled
Enough..my fingers are not designed to hit CTRL and ALT every five seconds and I need to switch back to my Vim heaven. Fortunately we have a Vim plugin Vlime to rescue us from the nightmare of learning and configuring a new editor with very steep learning curve. The only reasons I decide to try Emacs is that I want to learn Lisp language,which uses Emacs as its default IDE and I saw some weird professors using Emacs to send emails a long time ago.
Download the Vlime repository and start a vlime server
sbcl --load <vlime repo>/lisp/start-vlime.lisp.Type
\ccto build a connection between editor and the backend server. Type\csto list all current connections. Type\cdto close the current connection.\ssto evaluate the expression and\ito enable the interactive mode so you can just hitor by default to see the result of evaluation. \ofto compile the program and generate a new file ending with.fasl.