Portacle Lisp : Slime-repl-sbcl prompt keep auto-scrolling back

Viewed 122

as the title said, I am learning common lisp right now and using portacle, following Practical Common Lisp by Peter Seibel.

I found it quite annoying that the Slime-repl-sbcl buffer keep the writing at the end of the screen (using C-l or C-v doesn't help since once I try to execute an expression it will roll back to the end of the screen)

enter image description here Is there anywhere to improve this? (should I just write on a text file and compile it? the only similar subject I found was about Cider repl and couldn't understand it, since I am still new to lisp)

Thank you for your time

2 Answers

I would like this fixed too. No solution yet. In slime-repl.el, I found:

scroll-conservatively (variable):

A value of zero means always recenter point if it moves off screen.

my test wasn't conclusive.

slime-display-output-buffer (function), which calls slime-repl-show-maximum-output, which role is to

Put the end of the buffer at the bottom of the window.

I rewrote slime-display-output-buffer without this call, but that wasn't conclusive either.

Maybe I tested badly.

(I'm making this answer a wiki)

You would indeed typically write in a source file, and compile each expression separately. Use the REPL only to test functions or do simple computations. To compile functions (or really, any toplevel expression), use C-c C-c - bound to slime-compile-defun by default - when the point (= your cursor) is inside the function's code. The REPL will then "know" of it, so you can test it there, but as it is now written in file, you can also modify it without having to copy/paste anything ! Just make sure to recompile functions that you modify ! If you want to compile/load entire files at once, look at the other compilation commands, e.g. slime-compile-and-load-file (see the SLIME manual, and its Compilation section)

For your problem: there is Emacs variable, named comint-scroll-to-bottom-on-input (or something along those lines, can't remember exactly ...) which enables the behaviour you are seeing, so that you don't have to scroll back to enter new expressions. It is possible that SLIME has another variable which configuring this behaviour for its REPL; in that case, it would probably be named almost the same, and you can set it to nil to disable it.

Finally, don't hesitate to look at the other tools provided by SLIME ! For example, it comes with an "inspector" (see the relevant section), that you can use instead of evaluating expressions such as *db* in the REPL. In that simple case, it makes no real difference, but if you start having - say - hash-tables or different structures/classes, it becomes an incredible tool for interactive development, to examine the internal of almost everything, redefine things directly from within the inspector without needing complex accessors, and so on.

Related