3

How can I make swank forget all previously evaluated definitions?

I want it to undefine all macros, functions, and variables that where defined via evaluations (such as ,b evaluate buffer). And have it returned to the same state as when I reboot my PC and freshly start the swank server.

I tried:

  • the Clear-REPL (,-) command:

    This only appears to clear the screen (buffer).

  • CL-USER> (swank:restart-server) (from the REPL buffer):

    The server restarts but it still remembers my old defun and other defines.

  • CL-USER> (slime-restart-inferior-lisp) and `(slimv-restart-inferior-lisp)

    Both are undefined.

Rainer Joswig
  • 136,269
  • 10
  • 221
  • 346
Kasper van den Berg
  • 8,951
  • 4
  • 48
  • 70

3 Answers3

6

Slimv author here. I added a new command 'Quit REPL' to slimv. This closes the lisp process running the swank server by calling swank:quit-lisp, then closes the REPL buffer. You can use this one followed by another 'Connect Server' command to restart the REPL. The default mapping for 'Quit REPL' is <Leader>Q, so you can restart the REPL by the <Leader>Q<Leader>c sequence. Please see commits 44a50afc... on GitHub or a8abdbbc... on BitBucket.

Tamas Kovacs
  • 1,495
  • 7
  • 9
2

M-x slime-restart-inferior-lisp will restart things from scratch.

Xach
  • 11,774
  • 37
  • 38
  • 2
    A problem with this approach is that I'm using [tag:vim] with [tag:slimv] and not emacs with slime, so `M-x …` will not work. I'll try to find how to input `slime-restart-inferior-lisp` into vim and i'll check the implementation of the slime emacs mode to see how `slime-restart-inferior-lisp` is implemented. – Kasper van den Berg Oct 30 '15 at 12:09
1

This not solve directly your problem, but if you need to lost all your variables when restart, maybe working in a separate package should work for you.

CL-USER> (defpackage :my-separate-package (:use :cl :cl-user :swank))
#<PACKAGE "MY-SEPARATE-PACKAGE">
CL-USER> (in-package :my-separate-package)
#<PACKAGE "MY-SEPARATE-PACKAGE">
MY-SEPARATE-PACKAGE> (defvar a "a")
A
MY-SEPARATE-PACKAGE> a
"a"
MY-SEPARATE-PACKAGE> (in-package :cl-user)
#<PACKAGE "COMMON-LISP-USER">
CL-USER> (in-package :my-separate-package)
#<PACKAGE "MY-SEPARATE-PACKAGE">
MY-SEPARATE-PACKAGE> a
"a"
MY-SEPARATE-PACKAGE> (in-package :cl-user)
#<PACKAGE "COMMON-LISP-USER">
CL-USER> (delete-package :my-separate-package)
T
CL-USER> (defpackage :my-separate-package (:use :cl :cl-user :swank))
#<PACKAGE "MY-SEPARATE-PACKAGE">
CL-USER> a
; Evaluation aborted on #<UNBOUND-VARIABLE A {1004AD9AF3}>.
CL-USER> (in-package :my-separate-package)
#<PACKAGE "MY-SEPARATE-PACKAGE">
MY-SEPARATE-PACKAGE> a
; Evaluation aborted on #<UNBOUND-VARIABLE A {10055C6063}>.

Then you delete your environment and you do not have this variables, everytime you redifine the package

anquegi
  • 11,125
  • 4
  • 51
  • 67