This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

SLIME features in Lisp mode

6 posts · 11296 views

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?

Re: SLIME features in Lisp mode

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

Re: SLIME features in Lisp mode

Hey - thanks, that explanation taught me a lot. Much appreciated!

Re: SLIME features in Lisp mode

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

Re: SLIME features in Lisp mode

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!

Re: SLIME features in Lisp mode

This snippet from my ~/.emacs might help.
(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.