Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Can I configure Emacs to ask for confirmation before exiting on C-x C-c? (Sometimes, my fingers press this by mistake.)
Set the variable confirm-kill-emacs to something like yes-or-no-p.
A common alternative is to unbind the key using
(global-unset-key (kbd "C-x C-c"))
You can always quit via M-x save-buffers-kill-terminal
I use this, which workds in all Emacs versions:
(lambda () (y-or-n-p "Do you really want to exit Emacs? "))
Required, but never shown