[slime-devel] Re: Evaluate forms from within Lisp buffers and displaying the result in the REPL

Bill Clementson billclem at gmail.com
Mon Apr 23 05:32:15 UTC 2007

Hi Marco,

On 4/20/07, Marco Baringer <mb at bese.it> wrote:
> "Bill Clementson" <billclem at gmail.com> writes:
> > Hi Rainer,
> >
> > On 4/17/07, Rainer Joswig <joswig at lisp.de> wrote:
> >> I'm a bit used to the behavior of MCL when it comes
> >> to Lisp buffers and listeners. Maybe SLIME developers
> >> know how to achieve a similar behavior or would like
> >> to provide something similar.
> >>
> >> MCL allowed multiple Lisp text editor windows and listener windows.
> >> If there are multiple listeners one is the front most.
> >
> > SLIME does allow you to have multiple REPL windows. When you do "M-x
> > slime" multiple times, it will ask you whether you want to create an
> > additional repl.
> are you sure? i tried this today and multiple M-x slime will start
> multiple swank-servers in the lisp but you still only get one repl
> buffer (this looks a lot like a bug).

Yes, I'm sure. Well, at least I'm sure it does one specific thing
(which may not be what you think Rainer wants nor what he actually
does want ;-) ). I don't usually use multiple repl's, so I'm not sure
I understand the specific use case that Rainer wants to address. As I
see it, there may be 3 different types of "new" repl's that one could
want to have (which, depending on your specific use case may or may
not be what is required):

#1: You want to "play around" with some ideas but don't want to "muck
up" your existing lisp environment and repl. In that case, you
probably want to start up a new lisp instance and test things in a
completely independent repl. When I do "M-x slime" multiple times (and
say "n" to the "Create an additional *inferior-lisp*?" prompt), that
is exactly what I get - multiple lisp instances with a separate repl
for each one. I can use "C-c C-x c" to switch between them so I can do
my "mucking around" in the one repl and do the "real stuff" in the
other repl ("C-c C-x c" also controls which repl is "active" when
you're in a lisp buffer compiling/evaluating/etc code).

#2: You want to have multiple repl's on the same lisp instance (with
each repl sharing the repl history and */**/***/etc values). This is
useful if you want to use one repl for a demo but want to be able to
enter other commands in another repl to set up or modify an
environment for the demo. There are probably other use cases for this;
however, this is what I normally use #2 for. Again (as with #1), I can
use "C-c C-x c" to switch between the repl's so I have control over
which one is "active". Although SLIME does not provide any standard
function for automatically creating multiple repl's, it is easy enough
to do if you are using a lisp with threads. In your existing SLIME
repl, you can just enter "(swank::create-server :port some-port)" and
then in emacs do a "M-x slime-connect" and specify the host & port. If
you do this a lot, you could automate it with something like the

(defun slime-new-repl ()
  "Create additional REPL for the current Lisp connection."
  (if (slime-current-connection)
      (let ((port (slime-connection-port (slime-connection))))
	(slime-eval `(swank::create-server :port ,port))
	(slime-connect slime-lisp-host port))
      (error "Not connected")))

and just do "M-x slime-new-repl" whenever you wanted a new repl. As
you can see from the above function, although you can specify any
port, you can also just reuse the existing port for the separate repl,
so it's easy enough to do when you're ssh'ing to a remote machine too.

#3: You want to have multiple repl's on the same lisp instance (with
each repl having it's own repl history and */**/***/etc values). I
thought that it was possible to do this at one time with SLIME;
however, I just had a play and I don't think there is any way that you
can currently do this in SLIME.

I thought Rainer was after #1 when I initially replied. If he is after
#1 or #2, SLIME currently supports these types of multiple repl's. If
he was looking for #3, I don't think that is currently supported.
Maybe Rainer could indicate what specific use case he is trying to
address with multiple repl's.

Bill Clementson

More information about the slime-devel mailing list