Confirm-kill-emacs

Over at the Emacs subreddit, Danrobi1 opines that since the advent of use-short-answers, confirm-kill-emacs should be a boolean. His idea is that confirm-kill-emacs should merely specify whether to ask for confirmation or not and let use-short-answers choose the the particular form of the question if one is requested.

00-11 notes that Danrobi1 is misunderstanding the purpose of the confirm-kill-emacs variable: it was never about whether to call yes-or-no-p or y-or-n-p to ask if quitting Emacs is really what you want. What its purpose is and was is to specify a predicate that will decide whether to quit Emacs or not. There’s no reason it even has to communicate with the user. It just has to decide whether to quit or not based on whatever logic is coded into it.

I’ve had it set to y-or-n-p for as long as I can remember and haven’t thought about it in all that time. But 00-11’s response got me thinking. I originally set it to y-or-n-p because I kept inadvertently quitting Emacs by fat fingering some other shortcut and I’ve never looked back but there is one problem.

If I don’t remember to quit Emacs before rebooting my MacBook Pro, the reboot will hang waiting for Emacs to quit. That usually happens when there’s an OS update that I start off when I go to bed expecting to have a new OS in the morning only to find the system still waiting for Emacs to quit.

What if I could detect if my Mac is being rebooted? If I can, I can easily code up a predicate function that quits Emacs if so and calls y-or-n-p if not. The thought just popped into my mind so I haven’t had a chance to research it yet but it seems promising.

This entry was posted in General and tagged . Bookmark the permalink.