Skip to content

Instantly share code, notes, and snippets.

@ivey
Created March 7, 2012 20:21
Show Gist options
  • Save ivey/1995762 to your computer and use it in GitHub Desktop.
Save ivey/1995762 to your computer and use it in GitHub Desktop.
(defun intelligent-close ()
"quit a frame the same way no matter what kind of frame you are on"
(interactive)
(if (eq (car (visible-frame-list)) (selected-frame))
;;for parent/master frame...
(if (> (length (visible-frame-list)) 1)
;;close a parent with children present
(delete-frame (selected-frame))
;;close a parent with no children present
(when (y-or-n-p "Quit emacs? ") (save-buffers-kill-emacs)))
;;close a child frame
(delete-frame (selected-frame))))
(global-set-key (kbd "C-x C-c") 'intelligent-close)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment