help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A question about Sly/Slime: how do I invoke the inspector from Commo


From: Madhu
Subject: Re: A question about Sly/Slime: how do I invoke the inspector from Common Lisp?
Date: Sun, 05 Feb 2023 19:52:32 +0530

* Eduardo Ochs <CADs++6hZUDHNTTASjtDjtPw3MayhukKNnQNeEHDeCzu0Ad_8Ng 
@mail.gmail.com> :
Wrote on Sat, 14 Jan 2023 23:24:21 -0300:
> When we run this in the mrepl,
>
>   M-: (sly-inspect "(list 2 3)") RET
>
> The elisp function `sly-inspect' runs some preparations and then
> sends, via Sly->Slynk->SBCL, a sexp that SBCL should execute. I am
> trying to recreate that sexp, but the closest that I could get was
> this:

If you just want to call the inspector from lisp, you could do
*  (slynk::eval-in-emacs '(sly-inspect "(list 2 3)"))

after doing a (setq sly-enable-evaluate-in-emacs t)


>   (slynk:eval-for-inspector nil nil 'slynk:init-inspector "(list 2 3)")

[I've traced this execution path many times and I always forget the next
day and have to do it from scratch.  It's involved and I don't have the
energy to document it]

> but when I run that in the SBCL/Sly REPL I get this,
>
>   CL-USER> (slynk:eval-for-inspector nil nil 'slynk:init-inspector "(list 2 
> 3)")
>   ; Debugger entered on #<UNBOUND-VARIABLE *BUFFER-PACKAGE* {10043176C3}>
>   [1] CL-USER>
>
> so there's something missing - the CL sexp above needs to invoked
> inside some wrapper that sets up the correct context.
> Anyone knows how to call that function in right way?

You could make it work by evaluating, on the lisp side
```
(let ((SLYNK::*BUFFER-PACKAGE* (find-package "CL-USER"))
(SLYNK::*BUFFER-READTABLE* *READTABLE*)) (slynk:eval-for-inspector nil
nil 'slynk:init-inspector "(list 2 3)"))
```

Which would print out a form (which would get sent back to emacs with
SEND-TO-EMACS) in the normal course of thing when there is an emacs
connection.  Emacs would have first sent an asynchronous request with a
form with '(:emacs-rex ...) and with an ID which is handled by
SLYNK::EVAL-FOR-EMACS, which binds the buffer-package and read-table,
evaluates the form and sends results asynchronously back (to emacs with
SEND-TO-EMACS, tagging it with the same ID)

If you were only interested in the form you could also see it with, on
the lisp side with
```
 (slynk::inspect-object '(2 3))
```





reply via email to

[Prev in Thread] Current Thread [Next in Thread]