From: Madhu <enometh@meer.net>
To: help-gnu-emacs@gnu.org
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 [thread overview]
Message-ID: <m3r0v4gpjr.fsf@leonis4.robolove.meer.net> (raw)
In-Reply-To: CADs++6hZUDHNTTASjtDjtPw3MayhukKNnQNeEHDeCzu0Ad_8Ng@mail.gmail.com
* 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))
```
prev parent reply other threads:[~2023-02-05 14:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-15 2:24 A question about Sly/Slime: how do I invoke the inspector from Common Lisp? Eduardo Ochs
2023-01-15 18:55 ` Jean Louis
2023-02-05 14:22 ` Madhu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3r0v4gpjr.fsf@leonis4.robolove.meer.net \
--to=enometh@meer.net \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).