68
votes
Accepted
What do I do when Emacs is frozen?
When C-g doesn't work, you can sometimes get control back with:
pkill -SIGUSR2 emacs
As @Archenoth points out, sending the SIGUSR2 signal to Emacs turns on debug-on-quit. This can be useful, but you'...
57
votes
Debugging a frozen Emacs
Before resorting to gdb, if you're using a Unix-y operating system, you can try sending SIGUSR2 to the Emacs process, like documented in the DEBUG file mentioned in the other answer.
$ kill -SIGUSR2 &...
41
votes
Debugging a frozen Emacs
If the freeze goes away when you hit C-g, then you can use the built-in debugger. Type M-x toggle-debug-on-quit before sending the message, hit C-g when it freezes, and inspect the *Backtrace* buffer ...
13
votes
Accepted
How to set temporary halt after C-x C-c?
You can roll your own predicate function that waits for 3 seconds and invariably returns non-nil (unless it is interrupted with C-g):
(setq confirm-kill-emacs
(lambda (&rest args)
(...
11
votes
Accepted
How can I kill all unmodified buffers / files and delete their related frames?
One way would be to use ibuffer:
Open ibuffer (I have it bound to a key, but M-x ibuffer will work.)
Mark all modified buffers: * m
Toggle the marks, so that unmodified buffers are marked instead: t
...
7
votes
How to set temporary halt after C-x C-c?
You can use sit-for instead of using sleep-for plus t.
And the function need not be a command (interactive).
sit-for returns t if it waited and nil if the user interrupted the wait.
(setq confirm-...
6
votes
Accepted
how to quit describe-key function?
You cannot quit the describe-key command. The reason is simple: it cannot know whether you changed your mind about requiring a description of a key or whether you want a description of the key C-g. So ...
6
votes
Accepted
Closing emacsclient after quitting calc?
You could use hook calc-end-hook to hook delete-frame.
emacsclient -t --eval '(progn (add-hook (quote calc-end-hook) (lambda () (delete-frame))) (calc nil t))'
5
votes
Accepted
Stop GNU Emacs (GUI) on macOS from quitting
See kill-emacs-query-functions, which lets you query yourself to confirm quitting, to avoid accidental quitting.
See desktop.el, which lets you save most of the state of your session when you quit, ...
5
votes
5
votes
Accepted
Confirm quit only for keyboard shortcut, not for window close via mouse
you may define a separate command for C-x C-c like:
(defun keyboard-kill-emacs ()
(interactive)
(let ((confirm-kill-emacs 'yes-on-no-p)) ; temporarily enable the confirmation
(save-buffers-...
5
votes
Accepted
How to move the cursor to a newly opened buffer only when the newly opened buffer can be closed with q?
The easiest, and I think best, way to get behavior similar to what you describe is to customize option help-window-select to non-nil (M-x customize-option help-window-select).
If you do that then when ...
5
votes
How can I exit emacs without saving any changes
In most cases, an emacs instance runs for a very long time: what comes and goes is the buffer visiting a file. So instead of killing emacs as a whole, it is probably more useful to kill the buffer ...
4
votes
Accepted
How to debug slow respond or halt?
Little-known trick... You can send an interrupting debug signal to Emacs with kill/killall/pkill.
pkill -USR2 emacs
When sent to Emacs, the USR2 kill signal will interrupt whatever Emacs is doing ...
4
votes
Accepted
Interrupt ELisp interpreter from outside Emacs?
It's possible to unconditionally enter the debugger by sending the value of debug-on-event (should be USR2 by default) as signal as documented in the Error Debugging section in the Emacs Lisp manual.
...
4
votes
If I press CTRL-x CTRL-c and exited the scratch buffer in Emacs, will everything I typed be gone?
@Harald answered your question.
But I would not say "unfortunately". This is by design. Buffer *scratch* is designed for what its name suggests and its initial contents describe: It is a scratchpad,...
4
votes
How to exit minibuffer with one key?
You want to bind keys for the minibuffer in a minibuffer keymap. If you want a key to work in all minibuffers then bind it in keymap minibuffer-local-map:
(define-key minibuffer-local-map (kbd "&...
4
votes
Accepted
Why does `eshell` not create an active process In Emacs while `shell` and `term` do?
As mentioned in the manual page on Processes, the term process refers to an OS process. Emacs runs in a process, but can invoke other external processes and manage them as subprocesses. When you run M-...
3
votes
Accepted
How to make emacs prompt yes or no to save the session when desktop-save-mode is on?
My answer at https://stackoverflow.com/a/4485083/324105 might be of interest (even though this is almost the opposite to what you actually asked for).
With the custom my-desktop command, I only load ...
3
votes
Debugging a frozen Emacs
None of the other answers work for me. When my emacs hangs, I can only bring it back by killing and restarting it, but then after a while it hangs again. So there has to be a way to find out the ...
3
votes
Accepted
C-g has stopped breaking out of commands like `C-x C-f` and `M-x` in graphical emacs-25
This appears to be some kind of bug related to the GTK graphical toolkit. Switching to the Lucid build reportedly avoids the problem. For more about the difference between those toolkits, see my ...
3
votes
Accepted
how to read messages which appear after `C-x C-c`?
When killing Emacs, there are several hooks that may end up being called -- including, but not limited to, kill-emacs-hook, kill-buffer-hook (when a buffer is killed), write-file-functions hook (if a ...
3
votes
Accepted
Unable to quit emacs with `Wrong type argument: hash-table-p, nil`
What is the actual problem and what can I do about it?
The hash is only initialized in mu4e-headers-mode. Therefore, you should correct mu4e-execute-marks in the following way if you want to call it ...
3
votes
Accepted
How can I exit emacs without saving any changes
To exit emacs, use C-xC-c. It will ask you whether you want to save the changes. To prevent the question, precede the combination with C-u (but it will save the changes).
If you want to kill Emacs ...
2
votes
Emacs doesn't let me exit without selecting a coding system
When you use the -Q switch, you are telling emacs to not process both your init file AND the site init file. I suspect this prevents emacs from detecting and setting a default coding system. When ...
2
votes
Emacs doesn't let me exit without selecting a coding system
I temporarily solved the problem by deleting the file history located in ~\.eshell\. It appears that the entries of the last sessions of eshell are saved in this file. This solution is not satisfying ...
2
votes
If I press CTRL-x CTRL-c and exited the scratch buffer in Emacs, will everything I typed be gone?
The short answer is yes, unfortunately. But see this question for hints on avoiding this in the future.
2
votes
Accepted
How do I prevent `M-x` then `C-g` from entering the debugger?
To reproduce exactly the same behavior in emacs -Q:
M-x toggle-debug-on-quit
M-x C-g
Looks like you have the debug-on-quit variable set to non-nil. Either directly or by toggle-debug-on-quit command ...
2
votes
How to move the cursor to a newly opened buffer only when the newly opened buffer can be closed with q?
The functions that bring up the *Help* window will sometimes move you to that window and sometimes not. That depends among other things on how many windows you had open before. In the common case ...
2
votes
Accepted
EXWM - How to close another emacs opened inside exwm?
The problem is that any commands you execute such as C-x C-c will be captured by the Emacs instance running EXWM.
The first thing to try - which did not work for OP - is to execute M-x exwm-input-grab-...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
quitting × 34minibuffer × 6
key-bindings × 5
debugging × 4
exit × 4
frozen-emacs × 3
buffers × 2
hooks × 2
frames × 2
error-handling × 2
org-mode × 1
elisp × 1
osx × 1
shell × 1
emacsclient × 1
completion × 1
eshell × 1
mu4e × 1
term × 1
region × 1
commands × 1
process × 1
character-encoding × 1
compilation × 1
mark × 1