Friday, June 17, 2011

Prevent accidental iconify of Emacs

It is sometimes the case that you may accidentally press Ctrl-z while in Emacs and the Emacs Window magically disappears. Ctrl-z is by default bound to iconify-frame which is another way of saying minimize the window. To make this feature more pleasant, introduce a yes or no confirmation when Ctrl-z is pressed. Add the following code to your .emacs file.

(defun smart-iconify-or-deiconify-frame()
  (if (yes-or-no-p (format "Are you sure you want to iconify/deiconify Emacs? "))

(global-set-key [?\C-z] 'smart-iconify-or-deiconify-frame)


perusio said...
This comment has been removed by the author.
perusio said...


Ive added a test for the graphical environment and also rebind C-x C-z here.

tsengf said...

Great addition.