Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SLIME on Emacs with paredit in repl - how to prevent execution of incomplete but balanced expressions?

I use paredit on emacs with SLIME's repl. This means that at any point during my typing on the repl, my s-expressions are balanced.

However, they may not be complete, and I might want to continue typing inside them in another line, as follows:

CL-USER> (defun print-hello ()
            )

When I start a new line by pressing the enter key, however, the SLIME repl executes my incomplete expression. I want it to wait for me to complete the expression, as follows:

CL-USER> (defun print-hello ()
            (format t "Hello, world"))

How do I make this happen please?

like image 615
ARV Avatar asked Nov 14 '17 10:11

ARV


People also ask

How do I use slime in Emacs?

emacs. d/ . The first lisp file you load you may need to perform M-x slime , which means holding down either Alt or Escape, then hitting the letter 'x'. A prompt will appear at the bottom of the editor (in the minibuffer) where you type "slime" and hit enter.

How do you exit slime Emacs?

Place your cursor inside the 'slime-smart-quit routine and type M-x edebug-defun . Then exit Emacs as you normally would.


2 Answers

For that situations, when writing long s-expressions in REPL I think that the best way is to use the slime scratch buffer. you can edit it and after that execute with

C-j

No problem pressing enter inside the buffer, I'm using sly but the capture could be like this:

(defun print-hello ()
            (format t "Hello, world"))
 ; => PRINT-HELLO

Also another alternative is working without the last parent :-(

or as suggested in a comment by @jkiisky, type the expression and add in the middle of the s expression C-j

CL-USER> (defun
)
like image 160
anquegi Avatar answered Nov 08 '22 11:11

anquegi


Related to your question, lispy provides integration with SLIME.

I typically never type anything into the REPL buffer. Instead, I edit all code in place in the source file, and use e to eval the current sexp.

lispy is also a super-set of paredit, if compatibility is your concern.

like image 36
abo-abo Avatar answered Nov 08 '22 13:11

abo-abo