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

时光总嘲笑我的痴心妄想 提交于 2021-02-20 06:38:46

问题


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?


回答1:


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
)



回答2:


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.



来源:https://stackoverflow.com/questions/47283937/slime-on-emacs-with-paredit-in-repl-how-to-prevent-execution-of-incomplete-but

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!