From 207ce02a3371e0bcd67c90d1d7b00aa72c8eccf2 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 16 Dec 2019 05:42:40 -0500 Subject: [PATCH] ui/popup: fix quit-window sometimes breaking popups By burying the buffer and switching to a buffer that doesn't belong in a popup. --- modules/ui/popup/+hacks.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/ui/popup/+hacks.el b/modules/ui/popup/+hacks.el index 1a82e2ffe..66309c9de 100644 --- a/modules/ui/popup/+hacks.el +++ b/modules/ui/popup/+hacks.el @@ -29,6 +29,18 @@ ;; Don't try to resize popup windows (advice-add #'balance-windows :around #'+popup-save-a) +(defun +popup/quit-window () + "The regular `quit-window' sometimes kills the popup buffer and switches to a +buffer that shouldn't be in a popup. We prevent that by remapping `quit-window' +to this commmand." + (interactive) + (let ((orig-buffer (current-buffer))) + (quit-window) + (when (and (eq orig-buffer (current-buffer)) + (+popup-window-p)) + (+popup/close)))) +(global-set-key [remap quit-window] #'+popup/quit-window) + ;; ;;; External functions