Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to break out of an infinite loop in emacs lisp ? (environment: emacs)

Tags:

emacs

lisp

elisp

I tried using ctrl-c then :a

But It doesn't work here.

My code is like:

(defun game-repl()
    (loop (print (eval (read)))))

then I run

(game-repl())
look()
like image 803
Josh Morrison Avatar asked Dec 04 '22 21:12

Josh Morrison


2 Answers

(require 'cl)
(loop (setq x (read))
      (if (eq x 'exit)
        (return)
        (print (eval x))))
like image 179
Fred Foo Avatar answered Mar 18 '23 13:03

Fred Foo


Emacs modes often send an interruption signal to the inferior program only when you hit Ctrl-C twice in a row (i.e., the key sequence you are looking for is C-c C-c). In particular, this is true for SLIME.

This is because C-c is a prefix key that is usually combined with other keys to access a whole bunch of mode-specific features.

like image 39
Matthias Benkard Avatar answered Mar 18 '23 12:03

Matthias Benkard