Editing a LISP program on Ubuntu with vim
Trying to fill the gap in my computer science education I started to learn LISP again.
I am using the SICP “Structure and Interpretation of Computer Programs, 2nd Edition” book from MIT, that is used to be the book for the first semester students (!) to learn programming.
So I wanted to use the mit-scheme - a LISP interpreter written by the authors of the book. Unfortunately, there is no precompiled version for the 64 bit version of Ubuntu 8.10 Intrepid. But so far the scheme48 seems to be compatible to the examples from the book.
sudo aptitude install scheme48
The command line of the scheme48 is not very convenient so I ended just copying and pasting snippets from the editor into the interpreter window.
All the trolls say, the only way to edit and run LISP programs is to use emacs. There is a working automation solution for vim though - VIlisp.vim. It took me some time to get it work - here is my howto for Ubuntu 8.10 Intrepid:
1. Download and extract the VIlisp.vim
mkdir ~/.vim/lisp tar -C ~/.vim/lisp --strip-components 1 -xf vilisp.2.3.tgz
2. Install the required Perl modules
sudo aptitude install libterm-readline-perl-perl \ libterm-readline-gnu-perl libenv-ps1-perl
In addition I had to install the Pty package through the Perl package-maangement CPAN
sudo cpan cpan> install IO::Pty cpan> exit
3. Now we can run VIlisp which connects two windows
In the scheme interpreter window:
export PERL_RL=gnu perl funnel.pl $HOME/.lisp-pipe scheme48
I’ve created an alias for that
alias lisp='PERL_RL=gnu perl $HOME/.vim/lisp/funnel.pl $HOME/.lisp-pipe scheme48'
so I can just type
In the editor window:
or put something like following to your
autocmd BufRead,BufNewFile *.lsp,*.lisp,*.scm so ~/.vim/lisp/VIlisp.vim
so the functionality is loaded automatically for every scheme/lisp source file.
4. Now you can use shortcuts described in the README of VIlisp
\ecto evaluate current s-expression
\ebsends current visual block to the interpreter