开发者

Enabling autocomplete in sbcl

I have recently started to learn lisp, and have mainly bin using clisp and vim. I wanted to try sbcl as well, since this is often recommended as one of the best, free lisp compilers. There is one thing, though, which makes sbcl more difficult to use for me: I can not get autocomplete in the REPL, which I do have in clisp. That is, when I start sbcl and type the following (as an example),

* (requi<tab>

where <tab> is the literal tab character, I do not get a list of completions, but rather a verbose tab character. 开发者_运维问答In clisp, <tab> will complete the previous line to * (require.

As I am fairly new to lisp, the autocomplete functionality in clisp is really handy, so it would really be very convenient if anyone could explain how to get it in sbcl as well.


One way of getting an autocompleting repl in SBCL is to use linedit, from http://common-lisp.net/project/linedit/. A second is to use rlwrap, a readline wrapper, with a suitable completions file. (I think it's fair to say that neither of these is as commonly used as emacs, which of course also provides a completing REPL with a number of other useful features.)


I don't know of a way to get an auto-completing REPL in SBCL, but I find that interfacing with my lisp environment from within SLIME is quite handy and at that point, you can use C-c C-i for auto-completion.


Actually it's completely possible. Yes, You want to work with Common Lisp via Emacs and Slime (I prefer SLY). But it's another wall beginners hit.

You want to just play from the REPL? The following instructions allow autocomplete in SBCL with rlwrap.

https://www.cliki.net/CMUCL%20Hints

1) install rlwrap

2) create shell alias, for example putting text like

alias rs="rlwrap sbcl"

into your ~/.bashrc (or ~/.profile or whatever). (or you can continue calling sbcl rlwrapped via "rlwrap sbcl")

3)Edi Weitz created a completion list file that is now gone from his website, so i'm linking to the Internet Archive. save this wordlist into a file "sbcl" https://web.archive.org/web/20031207221537/http://weitz.de/files/cmucl_completions

4)You can try putting the file according to the instructions on Cliki, this will only apply for the user you are logged in under. I wanted it to work for all users, so I put the "sbcl" file into my rlwrap completion directory, which is in /usr/share/rlwrap/completions/

So now I have a file /usr/share/rlwrap/completions/sbcl That contains the words.

5)Create / adjust ~/.inputrc file add the line

TAB: complete

5) Done, now in a new terminal (or after reloading .bashrc) I can launch SBCL via rlwrap with the alias "rs" start typing (def (or whatever) and hit TAB, and get auto-completion suggestions.

Beginner Bonus - if you want to edit lisp in the terminal, from the REPL, in say, vim with parinfer, try magic-ed, which will allow you to edit files from the repl. Configuring SBCL to use ED is esoteric. This solves that issue for You. https://github.com/sanel/magic-ed With tab auto-completion and convenient way to edit lisp from the terminal, one can start learning Common Lisp in the terminal.


If you want to use sbcl, emacs and slime, follow this Modern Common Lisp on Linux tutorial. The tutorial mentions installing quicklisp and especially (ql:quickload "quicklisp-slime-helper"), an elispscript which getting slime to do autocomplete and more.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜