80 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'...
Tyler's user avatar
  • 22.3k
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 ...
glucas's user avatar
  • 20.6k
7 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 ...
choroba's user avatar
  • 2,045
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))'
Marco Wahl's user avatar
  • 2,876
6 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 ...
Drew's user avatar
  • 77.5k
6 votes

How to prevent displaying "Quit" when pressing C-g?

The main job of C-g (keyboard-quit) is to raise the quit signal. The message “Quit” comes from the error-message property of the symbol quit. You can make this an empty string: (put 'quit 'error-...
Gilles 'SO- stop being evil''s user avatar
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 ...
NickD's user avatar
  • 29.8k
5 votes
Accepted

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 "&...
Drew's user avatar
  • 77.5k
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, ...
Drew's user avatar
  • 77.5k
5 votes

What do I do when Emacs is frozen?

It also sometimes helps to abort-recursive-edit with C-].
Adobe's user avatar
  • 1,869
5 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 ...
Searene's user avatar
  • 499
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-...
zk_phi's user avatar
  • 66
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,...
Drew's user avatar
  • 77.5k
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-...
Trevor's user avatar
  • 56
3 votes
Accepted

How can I apply `(toggle-debug-on-quit)` ignore ` Debugger entered Lisp error: (minibuffer-quit)`

Try adding minibuffer-quit to debug-ignored-errors. You can do this using: (add-to-list 'debug-ignored-errors 'minibuffer-quit)
Lindydancer's user avatar
  • 6,160
3 votes

EXWM - How to close another emacs opened inside exwm?

The best solution is simply to hit C-c C-k (exwm-input-release-keyboard) which puts the X-window containing the inner emacs into char-mode. Then, when that window has focus, almost all keyboard input,...
Fran Burstall's user avatar
3 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-...
gregoryg's user avatar
  • 925
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 ...
phils's user avatar
  • 51.2k
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 ...
Tobias's user avatar
  • 33.2k
3 votes

Debugging a frozen Emacs

When nothing else works besides a hard kill of Emacs, I finally developed something that utilizes a little known feature of Emacs, what I call special events callbacks. It works by telling Emacs to ...
Joe's user avatar
  • 571
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 ...
npostavs's user avatar
  • 9,203
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 ...
lawlist's user avatar
  • 19.1k
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.
Harald Hanche-Olsen's user avatar
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 ...
pst's user avatar
  • 266
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 ...
muffinmad's user avatar
  • 2,300
1 vote
Accepted

Capturing "quit" in the completion prompt

@NickD's comment above lead me to this snippet: (let ((selected (condition-case err (completing-read "choose project:" projectile-known-projects) (quit &...
iLemming's user avatar
  • 1,263
1 vote

why do I need to use ctrl-G twice to quit a minibuffer prompt?

This was a dependency package -- org-random-todo depends on alert. Uninstalling and reinstalling org-random-todo seems to have cleared up the problem. So something in the installation seems to have ...
Dan Drake's user avatar
  • 615
1 vote

Aggressive C-g config

(advice-add #'undefined :override #'keyboard-quit) It is a hack.
mkcms's user avatar
  • 1,370
1 vote

How can I kill all unmodified buffers / files and delete their related frames?

There are two parts to your question: Kill all unmodified buffers. Delete their frames. For #2, do you really mean frames? In Emacs, a "frame" is a window-manager window, and an (Emacs) "window" is ...
Drew's user avatar
  • 77.5k
1 vote

How to save last Emacs session time and hostname to a log file on quit/close

Not exactly the answer you are expecting, but: If you are running on GNU/Linux in a GNOME environment, you could try the upcoming Emacs 26.1. Tramp offers a new method there, gdrive, which allows you ...
Michael Albinus's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible