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

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

Related

Issue compiling Chicken files in Geiser/Emacs

I installed Geiser in Emacs. In a scheme buffer, if I run C-c C-s, I can choose Chicken as the implementation. If I run C-c C-z, it starts an REPL and switches to it. My buffer seems to be correctly linked to the REPL. However, if I hit C-c C-c on a function definition, nothing is happening. Going to the REPL and calling my function fails (unbound variable). C-c C-c is bound to geiser-eval-definition.
What am I missing in my setup?

racket in geiser: switch language in live REPL to plai-typed

I've seen hits all around this basic issue, but nothing to help with, in particular, plai-typed. So, I can start a racket REPL in geiser, then type (require typed/racket) and it seems to take, i.e., I'm ready to go with basic typed racket. Normally, typed/racket is activated by having #lang typed/racket at the top of a source code file, then loading it. Likewise #lang plai-typed is how to use the specific "Programming Languages Applications Interpretations" racket language in source code. But then how can I switch to the plai-typed language in a running geiser racket REPL? Even better would be how to do this in an org-mode babel source code block.
In a Geiser REPL buffer, you could do C-c C-m plai-typed to get access to the plai-typed language. Additionally, if you're working with a Racket file, you could open that file in Emacs with C-x C-f /path/to/foo.rkt and then do C-c C-a to load the file into a Geiser REPL (it will create a new one if there is no existing REPL). This has the same effect as C-c C-m, but it will also run any code in the file. Note that the C-c C-a approach won't work in non-file buffers because the geiser-mode-switch-to-repl-and-enter function uses the Geiser ,enter command and it tries to supply ,enter with a path, which obviously won't work if you're in a buffer that's not associated with a file.

emacs `racket-mode` REPL not loading recognizing procedures

I just installed racket-mode in my emacs 24.3, when I run the REPL via racket-repl command, the REPL starts correctly, but some of the racket procedures/functions aren't recognized. i.e
> (class object%)
; class: undefined;
; cannot reference undefined identifier
> (enter! "test.rkt")
; enter!: undefined;
; cannot reference undefined identifier

The current value of the racket-racket-program variable is set to Racket.exe. On the other hand if I just run Racket.exe from the windows command line, then the REPL works as expected.
Any help with this is greatly appreciated.
When you do a racket-repl, that REPL initially opens with the equivalent of #lang racket/base. At the prompt you could type (require racket) to get the bigger language, including the class stuff like object%.
(There's an open issue about this. Feel free to chime in there.)
Instead of typing (enter! "test.rkt") at the prompt, try ,run test.rkt.
In fact, the easiest way to do this is with an Emacs buffer open on test.rkt. Then you can press C-c C-k a.k.a. M-x racket-run.
(Note that this leaves point in the test.rkt buffer. If you prefer point to go to the REPL, instead you can use M-x racket-run-and-switch-to-repl, bound by default to F5 like in DrRacket.)
TL;DR the most common use pattern with racket-mode is:
Visit a .rkt file in a buffer.
"Run" it with C-c C-c (or F5).
Explore in the REPL interactively as you wish.
Goto 2.
If your file contains #lang racket then the REPL picks up what language to use.
If no such line is present my guess is that racket/base is used -- and object% is not defined in racket/base.
Try entering this program:
#lang racket
(+ 1 2)
Then start the REPL and try your snippet again.

Failure to send buffer region to REPL in sml-mode

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.

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.