I once read somewhere, that we can set a global Emacs variable to T
(or NIL
, I don't know) in order to (roughly) make Emacs accessible from Common Lisp.
This information was in company with the warning, that this might have undesired side effects. I want to avoid that, that's why I just pushed the whole information to my minds /dev/null
.
But: Is there a way, to make the slime-repl
environment recognisable for the Common Lisp it hosts just in the narrow context of a function?
I would like to write a slime-clear-screen
function that preferably re-draws the whole Emacs window like it seems to be the effect of C-c M-o
in slime
. Alternatively, (format t "~%")
is repeated according to the number of lines of the current window size.
So I need to find a way to get access to the Emacs window controls or its size information, I guess.
But I have trouble to hear promising informations in the noise of Slime/Emacs keychord configuration requests and ANSI escape sequences.
Do you know, what I need for that? Or even better: Do you know a public library that already provides an equivalent function? Although I really like to tinker, I also explicitly look for commonly used or recommendable libraries to build-up a consistent framework of open-source "quasi-standard" libraries from the large buffet.
I thank you very much for your suggestions.
The variable is slime-enable-evaluate-in-emacs
, and if set to T you call eval-in-emacs
.
But there is a way to avoid doing so.
The Common Lisp side, Swank, uses send-to-emacs
to emit messages to the Emacs Lisp side, Slime. This is something like (:my-message x y z)
. But that must be a valid message, one among some that are recognized by both sides.
In slime.el
, there is a hook named slime-event-hooks
where you can process custom messages. It is used like this:
(or (run-hooks-with-args-until-success 'slime-event-hooks event)
(slime-dcase event
... ; builtin events
))
See for example contrib/slime-media.el
where a hook is registered when :on-load
happens.
The same mechanism exists on the Lisp side. In swank.lisp
, there is a special variable *event-hook*
that can contain additional code to run and handle events.
(or (run-hook-until-success *event-hook* connection event)
(dcase event
... ; builtin events
))
There is no example in contrib where it is used, as far as I know.
So there is definitely a way to implement a new contrib feature for Slime which doesn't look like a hack, you need to implement your own protocol by registering messages, and then do what you want in Emacs.