Skip to content

Instantly share code, notes, and snippets.

@perusio
Created June 19, 2011 16:57
Show Gist options
  • Save perusio/1034475 to your computer and use it in GitHub Desktop.
Save perusio/1034475 to your computer and use it in GitHub Desktop.
How to prevent accidental iconification in Emacs
;;; This is taken from planet Emacsen: http://tsengf.blogspot.com/2011/06/prevent-accidental-iconify-of-emacs.html.
;;; I've added a check to see if we're on a graphic environment.
;;; Prevent acidental iconify/suspend.
(when (window-system)
(defun smart-iconify-or-deiconify-frame ()
"Present a confirmation before suspending/iconifying."
(interactive)
(if (yes-or-no-p (format "Are you sure you want to iconify/deiconify Emacs? "))
(iconify-frame)))
;; Rebinding C-z to the new function.
(global-set-key (kbd "C-z") 'smart-iconify-or-deiconify-frame)
;; Rebinding C-x C-z to the new function. Overrides suspend-frame.
(global-set-key (kbd "C-x C-z") 'smart-iconify-or-deiconify-frame)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment