unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* A question about Sly/Slime: how do I invoke the inspector from Common Lisp?
@ 2023-01-15  2:24 Eduardo Ochs
  2023-01-15 18:55 ` Jean Louis
  2023-02-05 14:22 ` Madhu
  0 siblings, 2 replies; 3+ messages in thread
From: Eduardo Ochs @ 2023-01-15  2:24 UTC (permalink / raw)
  To: help-gnu-emacs

Hi list,

this is a question about a part of the guts of Sly/Slime that looks
very technical, but that is very close to the surface. Answers like
"it's better to ask this in the places such and such" are welcome -
I'm only asking this here because I couldn't find the places such and
such in the docs.

The standard way to learn Common Lisp is to use Emacs as its
interface, and use either Sly or Slime - I will say just "Sly" from
here onwards because it's what I'm using, but they're similar - to
make Emacs and CL talk to one another. This is explained here:

  http://joaotavora.github.io/sly/#Introduction

I am working on some "executable notes" - in this sense:

  http://angg.twu.net/eev-for-longtime-emacs-users.html

that would help eev users with no experience with Common Lisp to
install and test CL and Sly in just a few minutes. The initial parts
of these "executable notes" are working very well, but as far as I
know the people who like eev are a tiny subset of the people who like
to explore how things are implemented...

...but let me go straight to the point. Suppose that we have SBCL and
Sly installed, and we have a SBCL/Sly REPL running in a buffer that I
will refer to as the "mrepl". One way to open an "inspector" - see:

  http://joaotavora.github.io/sly/#Inspector

is to go to the mrepl and type something like this there:

  C-c I (list 2 3) RET
  C-c I (macroexpand '(defstruct mypoint x y)) RET

the first `C-c I' "inspects" a small object, the second inspects a big
one.

A more low-level way to invoke the inspector is to run this in the
mrepl:

  M-: (sly-inspect "(macroexpand '(defstruct mypoint x y))") RET

The buffer "*sly-events for sbcl*" holds a kind of log of the last
messages exchanged between Emacs and SBCL - or: "between Sly and
Slynk". We can inspect it with:

  (switch-to-buffer "*sly-events for sbcl*")

and it gives us a good starting point for understanding the details of
how this communication happens.



My Main Question
================
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:

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

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?


  Thanks in advance!
  Eduardo Ochs
    http://angg.twu.net/#eev



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-05 14:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).