SLIME features in Lisp mode

Discussion of programming Lisps using Emacs, including SLIME and other tools

SLIME features in Lisp mode

Postby JGraham » Wed Jul 17, 2013 12:28 pm

Hi there,

When I'm starting to type a function in the SLIME REPL and have typed, say, "(string-", I can press tab and I get a list of possible completions. I assume these are found dynamically from the module, so they include e.g. things I've not typed before.

However, when editing a source file in Lisp mode I can do M-/ which can cycle through options, but only those it's seen previously e.g. earlier in the source file or in the REPL.

I find it really inconvenient to have to C-x o to the REPL in order to see expansions for functions I don't remember (which is normally because I've not used them recently!). Does anyone know how I can get this aspect of REPL-like behaviour in a lisp-mode buffer?
JGraham
 
Posts: 3
Joined: Wed Jul 17, 2013 12:20 pm

Re: SLIME features in Lisp mode

Postby edgar-rft » Fri Jul 19, 2013 1:04 pm

With Emacs only very few things are as easy as they sound. But Emacs users know that there is always help available from Emacs itself.

The SLIME Manual Section 3.4 Completion Commands tells me that I shall use M-TAB to complete symbols. But if I press M-TAB, my window manager (fvwm2) shows me a list of all open windows, while in Emacs happens nothing, because the M-TAB never reaches Emacs at all.

But maybe M-TAB works for you (try this first).

If M-TAB doesn't work, then first the easy method:

  • If there is a SLIME menu in your Emacs menu bar in Lisp source code buffers then just simply look-up the key binding of the "Complete Symbol" entry in the SLIME menu.
Because Emacs key bindings can depend on the specific (X)Emacs or SLIME versions here is the full story:

  • The page of the SLIME Manual (same link as above) tells me that the SLIME Emacs function is called `slime-complete-symbol'.
  • If I press C-h b (describe-bindings) in a Lisp code buffer then a second buffer pops up with all current key bindings of the Lisp code buffer.
  • In the key bindings buffer I search for `slime-complete-symbol' and find that the function in my Emacs is also bound to C-c TAB.
If I type "(string-" in the Lisp code buffer and press C-c TAB then the same completion buffer like in the SLIME REPL pops up. If there appears no SLIME menu in Lisp code buffers and no `slime-...' functions in the key bindings buffer then there's something wrong with your SLIME setup.

- edgar
edgar-rft
 
Posts: 155
Joined: Fri Aug 06, 2010 6:34 am
Location: Germany

Re: SLIME features in Lisp mode

Postby JGraham » Sat Jul 20, 2013 5:52 am

Hey - thanks, that explanation taught me a lot. Much appreciated!
JGraham
 
Posts: 3
Joined: Wed Jul 17, 2013 12:20 pm

Re: SLIME features in Lisp mode

Postby edgar-rft » Sat Jul 20, 2013 8:45 am

The probably most important Emacs key-combo is C-h C-h, that pops-up a buffer with a list of all Emacs C-h... introspection functions.

- edgar
edgar-rft
 
Posts: 155
Joined: Fri Aug 06, 2010 6:34 am
Location: Germany

Re: SLIME features in Lisp mode

Postby JGraham » Sun Jul 21, 2013 1:02 pm

edgar-rft wrote:The probably most important Emacs key-combo is C-h C-h, that pops-up a buffer with a list of all Emacs C-h... introspection functions.


Awesome, that's really helpful - thanks again!
JGraham
 
Posts: 3
Joined: Wed Jul 17, 2013 12:20 pm

Re: SLIME features in Lisp mode

Postby nuntius » Sun Jul 28, 2013 9:14 pm

This snippet from my ~/.emacs might help.

Code: Select all
(define-key slime-mode-map
  (kbd "TAB") 'slime-indent-and-complete-symbol)


Searching for "slime-indent-and-complete-symbol" may find a better way to do this.

Slime is a bit complicated to configure and IMO the defaults are less than ideal. Search around; there are a number of blog posts describing tricks and tips, parenscript, etc.
User avatar
nuntius
 
Posts: 498
Joined: Sat Aug 09, 2008 10:44 am
Location: Burlington, MA


Return to Emacs

Who is online

Users browsing this forum: No registered users and 3 guests