Stopping infinite loops while running clojure tests in emacs with leiningen and swank/slime

前端 未结 3 725
囚心锁ツ
囚心锁ツ 2021-02-08 00:29

In certain kinds of code it\'s relatively easy to cause an infinite loop without blowing the stack. When testing code of this nature using clojure-test, is there a way to abort

3条回答
  •  春和景丽
    2021-02-08 01:12

    Yes, it is a common problem for programmers to write infinite loops in development :). And the answer is very simple. It's called "Interrupt Command" and it is C-c C-b

    Leiningen has nothing to do with this. This is SLIME/Swank/Clojure. When you evaluate code in Emacs you are spawning a new thread within Clojure. SLIME keeps reference to those threads and shows you how many are running in the Emacs modeline. If you're in a graphical environment you can click the modeline where it indicates your namespace and see lots of options. One option is "Interrupt Command"

    Eval (while true) and C-c C-b to get a dialog showing a java.lang.ThreadDeath error with probably just one option. You can type 0 or q to quit that thread, kill that error message buffer and return focus to your previous buffer.

提交回复
热议问题