Kasper van den Berg
Kasper van den Berg

Reputation: 9526

How to reinitialise swank?

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:

Upvotes: 3

Views: 794

Answers (3)

Tamas Kovacs
Tamas Kovacs

Reputation: 1505

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.

Upvotes: 6

anquegi
anquegi

Reputation: 11522

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

Upvotes: 1

Xach
Xach

Reputation: 11854

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

Upvotes: 2

Related Questions