Hacker News new | ask | show | jobs
by jrootabega 1353 days ago
This is also related to one of those sharp edges of Emacs that can cut you. "C-x c" is pretty close to "C-x C-c", which is the shortcut to exit Emacs. If for some reason, you DID mean to type "C-x c", it's easy to let your Ctrl finger linger a little too long and hit "C-x C-c" instead. And since x and c are next to each other on a US keyboard, it's also very easy (for me) to hit x and c at the same time with a single finger motion. The odds go up since so many actions start with "C-x"

(setq confirm-kill-emacs 'y-or-n-p) is one of the most important configs to start with, IMO. Or if you don't want to learn/use elisp, the equivalent Customize setting:

Options > Customize Emacs > Top-Level Customization Groups > Convenience > Confirm Kill Emacs

1 comments

Generally, if I have unsaved work Emacs prompts me to save, so I can C-g out then if I fat-finger kill-emacs.
I think that killing the entire app is jarring enough that it should never happen accidentally, regardless of unsaved work. It would be especially harmful for newer users, since they will find it harder to relax and feel comfortable with Emacs. But even for experienced users, Emacs state that you would want to preserve goes far beyond unsaved edits. Expensive startup computation, open buffers, window arrangement, ongoing rgrep operations, etc.