How can I abort an evaluation in Clojure Box (Emacs)? - emacs

I've been caught up in long running computations lately thanks to Project Euler and I'd like to know how to abort an evaluation and return to the REPL prompt. I'm running the standard Clojure Box version of Emacs. I tried the obvious REPL > Interrupt Lisp Process and Slime > Interrupt Command but neither kill the execution and return my REPL prompt.

Hit control c twice. If you're in *slime-repl clojure* then C-c C-c will kill the process and return you to the repl prompt. If you're in the *inferior-lisp* buffer, then you'll probably kill the clojure process, meaning that you'll have to restart slime (with M-x slime). If you don't have a slime repl buffer then, M-x slime-repl should give you one. You can use this as a repl to get a few extra features (try pressing the comma and tab, and see what's available ;)

When things get really fowled you can kill your lisp instance with M-x slime-quit-lisp and then restart it with M-x slime

Related

Emacs and Slime startup script

Every time I start work, I fire up Emacs, M-x cd to a working directory, M-x slime to start Slime, then do run (ql:quickload 'myproject) in the slime repl, (or , load-system myproject) followed by , +p myproject to switch the current package in the repl.
Lastly I run call a (start-server) in the repl to get my web server started.
I'd like for this all to be just a single Emacs keystroke or command. It's embarrassing that I have to ask this, since it's all lisp, but I can't quite figure out the interplay between Emacs and Slime here. Yet as a programmer I feel like I should automate all tedious processes - and I foresee several more steps being added to this.
I guess the tricky part is sending slime commands and then waiting for quicklisp to finish before sending the next command.
Any pointers would be appreciated!
Edit: Thanks to Svante for the C-c ~ hint, which was news to me
On the Emacs side, you can bind a key to a command than calls slime with additional arguments:
(defun my-lisp ()
(interactive)
(slime (concat "sbcl --load " <path-to-your-lisp-script>)))
And in your Lisp script, for example:
(ql:quickload :my-system)
(in-package :my-package)
(start-server)

Use repl for Hy in Emacs

I have successfully installed hy-mode from https://github.com/hylang/hy-mode. I now can open a .hy file in emacs and have syntax highlighting, and editing with paredit is a joy.
I however, don't know how to start a REPL. At the bottom of the github readme, it says:
When in hy-mode, you can launch a Hy REPL by launching a Lisp inferior
process
M-x lisp-inferior-process
That function, however, is not defined for me. What else do I need to install or check to be able to use the repl for Hy?
I am currently using:
GNU Emacs 24.3.1.
Have you tried to set inferior-lisp-program to "hy" and then doing M-x run-lisp?
This is the standard way (or maybe just the "way I know about") of having an inferior lisp process.
As of version 1.0.4 of hy-mode, you can start a hy repl buffer in Emacs using M-x run-hy or use the default key binding of C-c C-z.
In any Emacs mode, including hy-mode, you can use M-x describe-mode or the default key binding of C-h m to show key bindings for the current mode.

irb command history keystroke in irb on eshell

How can I access the command history when running irb in the emacs eshell?
When I run irb at the command line outside of emacs, I can use the up arrow to get the last command or ctrl-r to search the command history. In irb inside eshell, the up arrow does nothing (i.e. it runs eshell-previous-matching-input-from-input which does nothing in irb) and ctrl-r uses the emacs reverse search of the buffer instead of searching the command history. I guess irb never receives the up-arrow keystroke because it's bound to eshell-previous-matching-input-from-input, but I'm not sure how to fix it. Running (global-unset-key (kbd "<up>")) doesn't unbind the up-arrow in eshell and I'm not sure that's desirable anyway.
I know about inf-ruby, but I prefer using irb in eshell and besides up-arrow and ctrl-r don't work with that either.
It could be a problem with readline in irb, but I don't think so. conf.use_readline is nil on the commandline where irb command history works fine. Running irb --readline in eshell switches conf.use_readline to true but doesn't fix the up arrow or ctrl-r.
Emacs term mode (M-x term) in combination with C-c C-j / C-c C-k to temporarily allow yanking seems to be a good option. See another answer here.

How do I control emacs from a terminal?

I'm trying to drive emacs on OSX using Dragon Naturally Speaking running inside a Windows VM. Rather than running emacs in the VM, I'd like to drive an emacs (built from the HEAD of the repository) already running on the mac side of things. So, after a hunt through the emacs lisp manual I came up with the following snippets of lisp (currently running from the scratch buffer while I work stuff out):
;; This part is run from an emacsclient -t session
(defvar slave-frame last-event-frame)
;; and this is run in a GUI frame
(defadvice handle-switch-frame (after update-slave-redirect-advice activate)
(unless (eq last-event-frame slave-frame)
(redirect-frame-focus slave-frame last-event-frame)))
And all is well. I type into the terminal window, displaying buffer A and my typing appears in the GUI frame busily dsplaying buffer B. Great. Until I do C-x C-f or any other command that needs the minibuffer, at which point I get the error Terminal 1 is locked, cannot read from it.
I'm I barking up the wrong tree here, or is there a way to make redirect-frame-focus work nicely with commands that use the minibuffer?
Piers,
What behavior do you want, redirection to a minibuffer on the (Windows) client or a minibuffer on the server? Also, what version/flavor of emacs are you using?

Error remains once I got it while using swank-clojure

I use Emacs for clojure development, because Swank-clojure is a great tool.
But once I get an error on slime-repl buffer, the error remains, though I fixed it or it's no more.
Reproducing way:
Create a clojure project with a leiningen. $lein new myproject.
At core.clj, define a function that (defn f [] (+ 1 1))
Start a swank-clojure. M-x clojure-jack-in.
On a slime-repl buffer, evaluate (f). Of course it returns 2.
On a slime-repl buffer, evaluate (g). Of course it gets error Unable to resolve symbol: g in this context
After that, this error always appears when I try to evaluate anything in the slime-repl buffer.
C-c C-k doesn't help. So I always restart Emacs.app when I got an error on slime-repl buffer.
My Environment:
Mac OS 10.7.3, Cocoa Emacs 23.4.1, clojure-mode 1.11.5(from a Marmalade), leiningen 1.7.0.
In order to confirm an error and close the debugger, hit Q in the debugger window. (There may be restarts other than the QUIT restart available, but this, at least, should always work.)