What happens in emacs if exiting emacsclient with C-x C-c? - emacs

I've been trying to get used to using emacsclient because the load time is so much quicker than always running a full-fledged emacs process every time I want to open a file. I noticed in the emacs manual, it's suggested that I use C-x # to exit emacsclient. I'm so used to C-x C-c to exit that I often forget.
Is this a problem if I use C-x C-c to exit? Is there anything bad that can happen (e.g. corrupted files, zombie processes, etc.)

Is this a problem if I use C-x C-c to exit?
No, is this not a problem.

Related

emacs - Kill the buffer with terminal emulator

I am aware of this option:
Kill the *terminal* buffer with C-d
But I am still a newbie in emacs, what is the original method to do this? I tried C-x k but it doesn't like it, C-x C-c kills all my windows and buffers...
I assume you're using a buffer in term-mode (M-x term). term-mode is a bit different than most modes in that it has two submodes, char and line. In char mode it acts more like a terminal than emacs, as in a lot of normal keybinds are not available. Put it in line mode with C-c C-j to put it in line mode, then you can run most normal keybinds including C-x k. You can put it back into char mode with C-c C-k.
I use the multi-term package, which I think has better defaults than plain term-mode and as the name suggests makes it easy to have many terminal buffers.

How do I exit MELPA in emacs?

I'm trying to learn Emacs, and I've installed MELPA as a package manager. The only problem is that the only way I know how to exit MELPA is by quitting Emacs entirely. I'm sure there's a better way to do this. What is it?
Killing buffers with C-x k RET is generally good advice, but it is much easier to quit the package-list-packages screen by simply pressing q.
This also works to exit dired buffers, magit, and many other types of buffers that aren't text-oriented.
C-x C-f open file
C-x C-b open buffer list
C-x b open buffer
M-x execute command
C - ctrl and M - alt
Also take a tour here

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.

In Cygwin emacs C-c is read as C-g

I recently installed cygwin and emacs, and when I try to exit the program (by pressing C-x C-c) the minibuffer reads "C-x C-g is undefined". When I type C-c the minibuffer reads "Quit" just like if I had typed C-g. To the best of my knowledge, it's just reading the c key as a g in the minibuffer. However, if I type c into a scratch buffer it correctly displays c. Or if I type M-x c, it correctly reads as c in the minibuffer.
Is this a common problem? How do I fix this?
Thanks so much for any help! It's driving me crazy. Right now, I have to exit out of Cygwin when I want to quit emacs because C-x C-c won't close the program!
This is a problem with the default Cygwin console, but it doesn't happen with other Cygwin terminals such as mintty, rxvt, or xterm, so you might want to try one of those. Also, I believe the issue with the console is fixed in recent Cygwin snapshots.

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.