When I SLIME-EVAL-LAST-EXPRESSION something like (IN-PACKAGE FOO), it does not change *PACKAGE*. Any way to fix this?
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.
I assume you wanted it to change the package in the *slime-repl* buffer? To change the REPL's package, either type an IN-PACKAGE form there or use the ,change-package REPL shortcut (,ch TAB p TAB works :).
This behavior is actually vastly prefered to having a global package. Imagine you are testing a library you've written at the REPL in CL-USER. You've run (use-package :your-library) to import its external symbols. You can load up a source file for your library internals into a buffer and immediately C-c C-c a new or changed defun in that buffer, and the changes will wind up in the right package in your Lisp image without disturbing your test environment in the REPL.
Hope this helps, -bcd
Brian Downing bdowning@lavos.net writes:
use the ,change-package REPL shortcut (,ch TAB p TAB works :).
as does ,!p RET
Brian Downing bdowning@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.