Failure to send buffer region to REPL in sml-mode - emacs

Recently I have started dabbling in the sml-mode Emacs package for running SML code. The problem I'm facing is when I try to send across a region of my SML code/file to the REPL (which I think is the only logical way of writing multi-line functions in SML without getting troubled by the primitive REPL). Here is my workflow:
Open up an SML file (the SML mode shows in the bottom part of the window)
Open up the REPL if it isn't already running (C-c C-s)
Again get back to the SML file and write a function
Select the entire function and then press C-C C-r. I get an error "Not a `sml-prog-proc` buffer"
Now instead of selecting a region, just try to send the entire file to the REPL using C-C C-l; again the same error in the mini-buffer
Can someone please help me out in understand why this occurs and how to actually send across code from a script/file to the REPL when using SML? If it matters, I'm using SML/NJ.
TIA,
sasuke

This was bugging me as well, as it worked on some occasions but not on others.
If the sml process is killed with C-d (as recommended when issuing 'use' commands) and immediately restarted from the same buffer (C-c C-s), the error will occur whenever any of the 'send-to-repl' operations are performed.
The correct way (after killing the repl) is to switch back to the buffer containing the .sml file that is being edited and restart the repl from there (C-c C-s) or by either of (C-c C-r) or (C-c C-l).
HTH.

Related

How do I recover the old behavior of LaTex mode in emacs?

I have happily been using emacs's LaTeX mode for years (decades?). Up to emacs version 24.2.1, if I type C-c C-c in a LaTeX buffer that I was editting, the following would happen:
A prompt appears in the minibuffer for me to save, which I can acknowledge by pressing y.
A prompt appears in the minibuffer for me to latex the file, which I can acknowledge by pressing return.
latex is run on the file in the background. If there are no errors, a message in the minibuffer tells me so.
If there are errors, I am prompted to press C-c ` to examine them. This also (usually) takes me exactly to the the location of the error in the .tex file.
Only if I press C-c C-c again without making changes to the buffer, a propmt appears in the minibuffer for me to open the .dvi in xdvi, which I can acknowledge by pressing return.
I like the above behavior. It usually does what I want.
In 24.3.1, if I type C-c C-c in a LaTex buffer that I am editting, this is what happens:
A prompt appears in the minibuffer for me to run xdvi. I must type "latex" and press return. (xdvi is already open on the file, so why would I want to open it again?)
A prompt appears in the minibuffer for me to save, which I can acknowledge by pressing "y".
The frame is split into two windows. The latex command is run in a tex-shell in the bottom half.
If the latex run was successful, I must manually remove the tex-shell window from the frame, since it is waste of screen real estate.
If the latex run was unsuccessful, I must scroll through the tex shell buffer to see where they happened. Then I must seach the .tex manually file to find the corresponding code.
This is basically a disaster.
Is there some way to restore the old behavior?
Note: Please don't tell me to "use AUCTeX". If I had wanted to use auctex, I would doing so by now.

emacs-cider mode not connecting to cider-jack-in repl

I am using emacs for learning clojure. I have leiningen installed.
This is how my general workflow goes :
Open eshell in emacs
run lein new myapp
cd myapp\src\myapp\core.clj
write some code.
M-x cider-jack-in to open the repl
Now when i try C-c C-k to load the file in the repl, it does not go in that but instead in the small emacs command window.
My functions are also not visible in the repl.
How do i connect the clojure mode to the repl created with cider-jack-in ?
Clojure is different from many languages because the unit of compilation is the top level expression. So when you hit C-cC-k, cider-mode will run the equivalent of load-file on the current buffer and display the result of load buffer in the minibuffer (the space at the bottom of the screen). When evaluating Clojure the result of loading a buffer is the last s-expression in that buffer so when evaluation finishes the result of evaluating the bottom of the file will be briefly displayed at the bottom of the screen.
Once you have loaded the file, you can switch the REPL to that namespace by typing C-cM-n

message "Text is read-only" on multiple execution of un-changed buffer in python-mode

I am setting up my emacs (24.3) with python-mode. I would like to be able to edit the python buffer and execute it in python shell with "C-c C-C". This mostly works. But I am getting "Text is read-only" error if I stay in python code buffer and execute the buffer again.
It doesn't matter if the buffer has been changed and saved or if it is the same un-changed buffer - repeated C-c C-c produces the error. The solution seems to be visiting python output buffer and coming back to python code buffer and then executing - this works. But this breaks my flow. Does anybody else have the same problem? is this some possible mis-configuration in my setup?
Regards, Roman

Killing Racket Infinite Loops in Geiser

When I accidentally make an infinite loop by evaluating a form in emacs with geiser + racket, after a minute or so of waiting, eventually emacs will start to respond again. Unfortunately, every eval after that takes at least a minute. Usually, after the second or third eval, emacs will stop responding at all, and the fastest thing to do at that point it to restart the Ubuntu machine.
Is there some setting to prevent this in geiser, or a way to tell emacs to kill geiser?
Here's what I do when something hangs up.
Over the years, I don't recall Emacs being stuck in an unrecoverable state.
Use C-g. Repeatedly if needed. It calls keyboard-quit.
This should break any stuck loop and give you the ability to enter commands.
Now if geiser or any other process is misbehaving, just kill the buffers
that correspond to this process.
C-x C-b will give you the list of all buffers.
If you don't recognize the one that belongs to geiser, just restart Emacs
and open only geiser and see the buffer list again.
Now mark the misbehaving buffers with d.
Execute the deletion with x. That's it. You can
now restart geiser or whatever else. This approach is completely generic.
By the way, restarting the Ubuntu machine is too drastic.
When nothing works to stop the application with a window, but X still works,
use xkill utility. I've bound it to Ctrl-Alt-F12 for instance.
Then you just click on a window you don't like and it's gone.
If xkill doesn't work, switch to a virtual terminal with
Ctrl-Alt-F1 and use htop to kill the application.
According to the REPL documentation, you should be able to use C-c C-q to kill the REPL. From the link to the REPL documentation, go to the First Aids section; it's near the bottom of it.
Geiser hangs on loops here also. In emacs 24.3.1 running on Debian 7 updated two days ago; M-x run-geiser; Then one gets a window with a REPL prompt. All is good, but then say > (define f (* f (- n 1))), then > (f 3) and the process in the buffer is locked up. C-c C-c and C-c C-q do nothing. Killing the buffer, answering yes to the query of killing subprocesses, and then restarting does get one to a REPL prompt with all definitions gone.

Yanking text into a terminal running in Emacs

I am unable to yank text into a terminal running in Emacs.
This is my procedure:
I killed the string "date" from one buffer and yanked it into the terminal in another buffer and hit return.
The terminal behaves as if I typed nothing. It just returns the prompt back.
I am using OS X 10.5.8 and Emacs 23.1. I have tried this procedure on Aquamacs, Carbon Emacs, and the release from http://emacsformacosx.com/. They all show this weird behaviour even in their default configurations with my .emacs file empty. What could possibly be causing this?
By "in a terminal" I assume you mean you're running Emacs's built-in terminal emulator. Ordinarily, the terminal emulator transmits most keys exactly as typed to the shell process. Type C-c C-j in the terminal buffer to put it into a state where ordinary Emacs key bindings are available. You'll see the mode line change from (Term: char run) to (Term: line run).
Addendum:
Yanking text without leaving char mode is a little tricky; the relevant function, however, is term-paste (not yank, which merely inserts the text into the terminal buffer without sending it to the inferior process). term-paste will immediately send the most recent kill to the inferior process, but doesn't provide the fancy yank functionality you're probably used to (like M-y to cycle through prior kills). You could run term-paste as an extended command: C-c M-x term-paste RET.
Probably the easiest solution is just to temporarily go into line mode (C-c C-j) when you have something to paste, and then immediately go back into char mode (C-c C-k). Or even easier, just stay in line mode all the time. I often do this when I have a terminal logged into an Oracle SQL*Plus session. I rarely notice the difference, but I get all sorts of convenient Emacs functionality, like being able to type M-p to cycle through a long, previously-typed SQL statement.
I would have assumed that you could always start off in line mode like this:
(add-hook 'term-mode-hook 'term-line-mode)
...but it doesn't work for me. Don't know why.
In the buffer with the terminal running, put the terminal into line mode with C-c C-j. To paste in your text, now press S-Insert (that's Shift-Insert). If you need the terminal to go back to char mode afterwards, it's C-c C-k.
When all else fails I just highlight the text and click Edit->Copy then right click in the other emacs buffer and click paste.