[slime-devel] How to determine the top caller in Slime's REPL

Philippe-André Lorin palpalpalpal at gmail.com
Fri Jun 9 14:48:05 UTC 2006


Hello everybody. I'm a Slime newbie, trying to develop an application
that is intended to be run in Emacs + Slime to allow for interactive
modifications.

I posted this to comp.lang.lisp, but got few replies; it is probably
more appropriate here.

In Slime, I need to be able to determine dynamically whether the "top
caller" of the currently executing code is some specifically marked
expression, or just one of all the other expressions typed at the REPL
which might be running in parallel.

An example should make the idea clearer.

(defun f ()               ; This function is just here to show that the
   (in-marked-expression)) ; test is not necessarily lexically enclosed
                           ; in the marked expression.

(mark-and-eval
  (do () (nil)         ; Just an infinite loop, to make sure the
                       ; expression will be running forever in parallel.
    (assert (f))))     ; Here, IN-MARKED-EXPRESSION must always return T.

(f)                 ; Note that the preceding (DO ...) is still running.
=> NIL              ; Here, IN-MARKED-EXPRESSION must always return NIL.

I can write the marked expression with complete freedom (for instance, I
can add wrappers around it or preprocess it), but all the other
expressions typed after it at the REPL are not under my control.
Among the ideas I've tested, the following one sounded the most
promising, but it doesn't work. I don't understand why.

(defun in-marked-expression ()
   (not (null (find-restart 'restart-in-restart-case)))) ; Are we in the
                                                         ; restart-case?

(defun f ()
   (in-marked-expression))

(restart-case
     (do () (nil)
       (assert (f)))
   (restart-in-restart-case () nil))

(f)
=> T                ; :(

I also tried using a special variable or processes, with no luck. Any ideas?

PS: I'm using CMUL on Ubuntu.



More information about the slime-devel mailing list