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

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

A question about Sly/Slime: how do I invoke the inspector from Common Li


From: Eduardo Ochs
Subject: A question about Sly/Slime: how do I invoke the inspector from Common Lisp?
Date: Sat, 14 Jan 2023 23:24:21 -0300

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



reply via email to

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