Go back from ess-remote state in emacs - emacs

Sorry for any duplicates, but I am lacking the correct words to google the answer myself.
I am using ess with emacs to run R in a terminal in emacs, kind of like:
Start emacs
M-x term, start bash
Start R (interactive mode)
M-x ess-remote, select R as language.
When I quit R, I want to turn off the ess-state and use the normal "term" state.
I am using GNU Emacs 23.2.1 and ess v. 13.05.

No easy way. Unless you use screen, the preferred way to use ESS with remotes is through tramp. See the official docs.

Related

How to use terminal keyboard shortcuts inside emacs multi-term

I know there's some questions that are kind of related to this already, and I know you can do stuff like
(defun term-send-esc ()
"Send ESC in term mode."
(interactive)
(term-send-raw-string "\e"))
but it would be very convenient if there was kind of a univerisal override keybinding. For example, I just ssh:ed into a remote server and tried to nano a file and couldn't figure out how to exit because Ctl-x listens for emacs bindings. Is there such a thing?
There are two term sub modes, term-char-mode (C-x C-k) and term-line-mode (C-x C-j). Char mode is closer to a terminal, line mode is closer to a regular buffer. IIRC, multiterm starts in char mode, but it rebinds some keys to make it more Emacs-like. Look at the keys that multiterm rebinds; it has some alists that are used to modify the existing term-mode keymaps instead of using its own keymap. Or use sane-term, which is not much more than some commands to create new term buffers (no mucking with key bindings).
Ctl-x listens for emacs bindings.
Not in the default term-char-mode it doesn't, so your problem is most likely with your own config.
Run a terminal in emacs -Q to confirm the standard behaviour.

running scheme from emacs

I'm a newbie to LISP.
I am attempting to invoke the scheme interpreter from within emacs (version 23 running on windows). I loaded the xscheme library by telling emacs to M-x load-library and then entering xscheme at the prompt in the minibuffer. The library loaded, and then I issued the M-x run-scheme command. (I realize that all this loading can be done from .emacs at startup, but I am not concerned with that at the moment.)
So far so good - the *scheme* buffer has been created, and now I'm hoping that I'm able to talk to the scheme interpreter.
However, when I try to evaluate something in that *scheme*buffer (e.g. (define shoe-size 14)), I get this Output file descriptor of scheme is closed message in the minibuffer.
Does anybody know how to fix this in emacs?
(Also, how does one set the major-mode as REPL in the *scheme* buffer?)
Thank you.
Try setting the scheme-program-name variable to the path to your Scheme interpreter. The major-mode of the scheme buffer is probably just comint and you cannot do much about it unless you switch to something more capable like Geiser - something that I'd recommend you do.
Add this line to your .emacs file:
(setq scheme-program-name "gsi")
(Replace "gsi" with the name of your Scheme interpreter.)
You can then start the interpreter with M-x run-scheme. You can evaluate pieces of code by using C-x C-e (to evaluate the sexp before the point) or with C-M-x to evaluate the sexp you're in right now. You can also load a file with C-c C-l.
I'll start by saying that I'm very new to programming, scheme and SICP, but I'm trying to work through the course and watch the lectures that are online.
I'm running emacs on Ubuntu 12.10 and I really wanted to get MIT scheme working in emacs instead of relying on Edwin.
The above tips didn't work for me, but here's the step-by-step instructions that did work:
Install emacs 24 from the Ubuntu Software Center (search "emacs" and install it!)
Open a terminal (ALT + CTRL + t)
Go to your home directory (cd ~)
Open the hidden file .emacs in gedit (gedit .emacs)
On the first line of the file, type exactly what's after the colon: (require 'xscheme)
Save the changes to .emacs
That's it!!!
You can now open .scm files in emacs and use commands like C-x C-e.
*directions courtesy of http://alexott.net/en/writings/emacs-devenv/EmacsScheme.html#sec14
My guess is that it's just a known issue I still dunno how to sort that out (it's out of my current skills) but I got a macro that probably helps: just after writing the s-exp you can do Cc-Cz (it calls the geiser REPL) then C-spc, C-M-b, M-w, C-x-o, C-y and RET.
There are a variation (same, placed just after writing the s-exp): C-spc, C-M-b, M-w, C-c Cz, C-y and RET

What are the "Programmer shortcuts" in emacs?

I would like to know what are all the programmer-useful shortcuts that exists in emacs.
I come from a netbeans background and I am trying to make myself comfortable with emacs -text only environment. So I am looking at shortcuts for "refactoring" the code, "auto-completion", "go to definition" etc.
How can all these be achieved in emacs ? What are other programmer-useful shortcuts ?
I'll be using emacs basically for LAMP, javascript, C, C++.
ps - you can safely assume that I know how to open a file, save a file, navigate and whatever is in the tutorial in emacs.
For auto-completion, use etags with M-xtags-search or M-xetags-select-find-tag. I use macros often to do repetitive tasks. C-x(<string of useful tasks>C-x). Also, M-xalign-regexp to beautify the code and make it more readable.
You should find most of the most used features by Emacs users in this question's answers here at Stackoverflow.
Check this site
Some the important keybindings that are not there in the tutorial are:
Previous matching bracket: C-M-b (if it doesn't work, try ESC followed by C-b)
Next matching bracket: C-M-f (or ESC C-f)
Go to start of block: C-M-u
Go to end of block: C-M-d
Start of function: C-M-a
End of function: C-M-e
Outline mode: C-u 1 C-x $ (C-x $ to revert)
Newspaper mode: C-x 3 M-x follow-mode (especially useful with today's wide-screen monitors!)
Vertical Copy
Sometimes you will need to copy a vertical patch of data, e.g. one column in a table. First press C- where you want to start copying. Then go to the end of the column and press C-x r k. To paste the column press C-x r y. (If you don't want to delete original column, just press C-_ there once to restore it and then press C-x r y at target.)
To start, here is one :
Meta - / -> does code completion
M-x diff-buffer-with-file
M-x revert-buffer
When working with versioning (I use git), M-x diff-buffer-with-file is really useful. When you have a file open in a buffer in emacs, then you do a git checkout or some other action that touches that file, emacs will complain at you when you try to edit the buffer. M-x diff-buffer-with-file is helpful to see if you will break anything by keeping what's in the buffer. If something has changed and you want to grab the file from disc and put it in the buffer, do M-x revert-buffer.

A few Emacs noob questions

Sorry if these are obvious answers but I've googled around and can't seem to find what I'm looking for.
When I have multiple files open in split screen mode using C-x C-3 how do I close JUST the window I'm currently in and no other?
I'm using Ruby and it doesn't seem to auto indent my def end correctly.. is there a Ruby plugin that will fix this?
Is there a command to go to a specific line?
How do I interpret ruby from within emacs?
1. When I have multiple files open in split screen mode using C-x C-3 how do I close JUST the window I'm currently in and no other?
To close current view C-x 0. (Btw, I think you're referring to C-x 3.)
2. I'm using Ruby and it doesn't seem to auto indent my def end correctly.. is there a Ruby plugin that will fix this?
Have a look at
ruby-mode for emacs
RubyMode
3. Is there a command to go to a specific line?
Sure, M-g g (or M-x goto-line)
4. How do I interpret ruby from within emacs?
Don't know. You could try rubydebug.
You can also see C-h b which will give you key binding for the current-buffer to give you a lot of additional things that you might need. Once you install any Ruby Mode, you can also use C-h m to see key binding for that specific modes in your current buffer, including ruby mode.
for Q3) in addition you might want to know
C-h w COMMAND
will always show you the key binding for a funcion
C-h w goto-line RET
goto-line is on M-g g, M-g M-g, <menu-bar> <edit> <goto> <go-to-line>
for Q4) you could start a shell in a buffer, either M-x eshell or M-x shell and the simply run your script there.
Using the eshell configuration in [1] you can easily switch between the shell and your script source (pressing C-z).
[1] http://www.emacswiki.org/alex/2008-08-19_Emacs_on_Windows

Certain keybindings don't work when using emacs in a terminal

I load GNU emacs in it's own window by typing emacs in the terminal.
I like to use the keybindings from pc-selection-mode, which allows you to highlight characters using shift-right or shift-left, or entire lines by pressing shift-up or shift-down.
The problem is that when I run emacs in the terminal by typing emacs -nw, the latter 2 keybindings don't work. I can highlight characters using shift-left and shift-right, but pressing shift-up and shift-down doesn't do anything. The cursor stays where it is.
How do I fix this problem? Why is it even occurring? I'm using GNU Emacs 23.1.1, and I've confirmed that the same version is being used both when emacs is in it's own window and when emacs is running inside the terminal.
Thanks for any help
A lot of times the bindings just aren't listed, or are mapped wrong. You can try M-x show-lossage (or C-h l) to see if the escape sequences reach emacs or not. If they do, you might want to try xterm-extras -- it's always worked even as I migrate between different versions of linux and solaris, and as I ssh between them (which is often a source of problems).