2

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.

2
  • Well, I think it is not possible the way I want it. Maybe it would be more recommendable to connect with an external repl and do stuff that should clear the screen say, refresh it, there. Maybe also with cl-ncurses, or cl-readline already provides useful tools. Commented Mar 22 at 9:56
  • Emacs would be a better place to ask this. Commented Mar 22 at 13:59

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

I misunderstood your question and thought you search for a way to clear the screen in a common lisp REPL.

Which command could be used to clear screen in CLISP?

There you find methods like:

(screen:with-window (screen:clear-window screen:*window*))

or

(defun cls()
  (format t "~A[H~@*~A[J" #\escape))

(cls)

That works even on naked terminal CLISP or SBCL (while with SBCL only the latter one). The last one actually prints so many empty lines - that it seems that it is a cleared screen.

1 Comment

Ah, now I see: "Request clarification" is the new way to go for a normal comment. Thank you as well for your answer :-) Yes, the "clear screen" ASCII sequence crossed my path as well. But yes, I was after the SLIME repl. And I think, sooner or later I cannot help it, I will have to try out @coredumps recommendation. But I think, for now, it becomes more interesting to M-x slime-connect with a SBCL terminal and use cl-charms there. - That was still on the agenda ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.