
Today I read a blogpost by en emacser blogger (tsengf) about quitting emacs accidentally.
He writes a function to avoid closing emacs by accident when there's an opened file that belongs to any of your projects.
My approach is somewhat different:
Usually, when I have emacs opened, I have some processes running within it. That makes emacs warn me when I press c-x c-c by accident, and asks for confirmation (the same way as if I had unsaved buffers)
Anyway, sometimes my muscle memory screws everything, and presses 'y' without asking my conscious mind.
Here are a couple of solutions that work to some extend.
The first one is the radical one. Just do not shut up emacs. Yes, as strange as it seems, I rarely have to close emacs while my computer is on.
global-unset-key c-x c-c
Then you have to exit emacs with the name of the whole command save-buffers-kill-terminal
As a not-so-radical solution, my bet is for desktop-save to save every session in your home directory.
(defun desktop-save-main ()
(desktop-save "~/"))
(add-hook 'kill-emacs-hook 'desktop-save-main)
Then, if you want to recover the state of the previous session, you have to eval (desktop-read) or (desktop-read "~/") if you aren't on your home dir.
If you had sql sessions, erc sessions, or any other comint buffer... well... you lost them.
PS: If you happen to know how to make this blog/post appear on the emacsen planet, please comment, or mail me, or twitt it to some emacs aggregator.... or just twitt the post FEED ME MOAR RSS's!
Do not you use GNU/Emacs as a daemon yet?
ResponderEliminarhttp://www.gnu.org/software/libtool/manual/emacs/Emacs-Server.html
Don't quit emacs more!
Hello David,
ResponderEliminarI use it in some machines, but anyway, c-x c-c closes all clients at once (at least, in my setups).
In fact I use a bastarized version of bill clemeston emacsclients setup. Anyway, it's a nice topic for another post. :)