From eaad8ce86a3ecbb223a65e3dd23dba12f4525b6f Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Wed, 26 May 2021 00:44:51 -0400 Subject: [PATCH] Add a function/keybind to delete invisible frames Workaround for annoying "Attempt to delete a surrogate minibuffer frame" issues when closing frames --- .emacs.d/init.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 778744a..ab4bf4b 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -295,12 +295,19 @@ #'(lambda () (setq-local show-trailing-whitespace t)))) (use-package frame :demand + :bind ("C-x C-S-c" . delete-invisible-frames) :config (defun suspend-frame () "If running in a secondary tty, call `suspend-tty', else nop" (interactive) (when (eq (framep (selected-frame)) t) - (suspend-tty)))) + (suspend-tty))) + (defun delete-invisible-frames () + "Delete all non-visible frames, to fix \"Attempt to delete a surrogate minibuffer frame\" issues" + (interactive) + (mapc (lambda (frame) + (unless (frame-visible-p frame) (delete-frame frame))) + (frame-list)))) (use-package cc-styles :config