[slime-devel] (in-package foo)

Helmut Eller e9626484 at stud3.tuwien.ac.at
Sat Oct 23 11:50:24 UTC 2004


Brian Downing <bdowning at lavos.net> writes:

> On Fri, Oct 22, 2004 at 06:38:48PM -0700, Neo-LISPer wrote:
>> When I SLIME-EVAL-LAST-EXPRESSION something like (IN-PACKAGE FOO), it
>> does not change *PACKAGE*. Any way to fix this?
>
> When you use one of the evaluation commands to run an IN-PACKAGE form in
> an editor buffer, it changes the package of that buffer (which is
> displayed in the modeline).  Future evaluation/compilation commands in
> the buffer will be run in that package.  The buffer package is also
> autodetected when first loading a buffer.

Let me add some details.

slime-eval-last-expression, actually SWANK:INTERACTIVE-EVAL, binds
*package* to the "buffer-package" before evaluating the expression. So
assignments to *package* are only visible during the evaluation itself
and are undone afterwards.

The idea is that the buffer-package is a property of the buffer or
file and not some state in the Lisp system.  In ordinary Lisp buffers,
SLIME searches backwards for something like (in-package <name>) to
determine the buffer-package and sends that name to Lisp (together
with the expression).  The REPL commands work a bit differently: they
take the package name form a buffer-local variable which is explicitly
synchronized with the current state on Lisp side.  In some other
buffers, like sldb or apropos, there's also a buffer local variable
for the buffer-package.

So, if are in an ordinary Lips buffer and you want to evaluate an
expression in a particular package, it is the easiest to insert a
in-package form before that expression.

Helmut.




More information about the slime-devel mailing list