From 6de185409f6d88626b02bcc64f5e660e01396f07 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 25 Sep 2017 02:58:59 +0200 Subject: [PATCH] New macro: save-popups! --- core/autoload/popups.el | 18 ++++++++++++++++++ core/core-popups.el | 13 +------------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/core/autoload/popups.el b/core/autoload/popups.el index 53a47f62e..f920f82de 100644 --- a/core/autoload/popups.el +++ b/core/autoload/popups.el @@ -196,6 +196,24 @@ window parameter." ,@body (setq shackle-rules old-shackle-rules))) +;;;###autoload +(defmacro save-popups! (&rest body) + "Sets aside all popups before executing the original function, usually to +prevent the popup(s) from messing up the UI (or vice versa)." + `(let ((in-popup-p (doom-popup-p)) + (popups (doom-popup-windows)) + (doom-popup-remember-history t) + (doom-popup-inhibit-autokill t)) + (when popups + (mapc #'doom/popup-close popups)) + (unwind-protect + (progn ,@body) + (when popups + (let ((origin (selected-window))) + (doom/popup-restore) + (unless in-popup-p + (select-window origin))))))) + ;;;###autoload (defun doom/other-popup (count) "Cycle through popup windows. Like `other-window', but for popups." diff --git a/core/core-popups.el b/core/core-popups.el index c340795a6..815fbb513 100644 --- a/core/core-popups.el +++ b/core/core-popups.el @@ -237,18 +237,7 @@ and setting `doom-popup-rules' within it. Returns the window." (defun doom*popups-save (orig-fn &rest args) "Sets aside all popups before executing the original function, usually to prevent the popup(s) from messing up the UI (or vice versa)." - (let ((in-popup-p (doom-popup-p)) - (popups (doom-popup-windows)) - (doom-popup-remember-history t) - (doom-popup-inhibit-autokill t)) - (when popups - (mapc #'doom/popup-close popups)) - (unwind-protect (apply orig-fn args) - (when popups - (let ((origin (selected-window))) - (doom/popup-restore) - (unless in-popup-p - (select-window origin))))))) + (save-popups! (apply orig-fn args))) (defun doom*delete-popup-window (&optional window) "Ensure that popups are deleted properly, and killed if they have :autokill