 (defvar doom-popup-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map [remap doom/kill-real-buffer] 'doom/popup-close)
+    (define-key map [remap evil-window-delete]    'doom/popup-close)
     (define-key map [remap evil-window-move-very-bottom] 'ignore)
     (define-key map [remap evil-window-move-very-top]    'ignore)
     (define-key map [remap evil-window-move-far-left]    'ignore)

(defun doom*popup-init (orig-fn &rest args)
  "Enable `doom-popup-mode' in every popup window and returns the window."
  (let ((window (apply orig-fn args)))
    (with-current-buffer (window-buffer window)
      (doom-popup-mode +1))
    ;; NOTE orig-fn returns a window, so `doom*popup-init' must too
    window))

                 (delq 'process-kill-buffer-query-function
                       kill-buffer-query-functions)))
            (kill-buffer (window-buffer window)))
        (doom-popup-mode -1)))
    (delete-window window)
    (unless dont-redraw (redraw-frame))))

;;;###autoload
(defun doom/popup-close-all (&optional dont-kill dont-redraw)
  "Closes all popups (kill them if DONT-KILL-BUFFERS is non-nil). Then redraw
the display (unless DONT-REDRAW is non-nil)."
  (interactive)
  (let ((orig-win (selected-window)))
    (mapc (lambda (w) (doom/popup-close w dont-kill t))
          (--filter (and (doom/popup-p it) (not (eq it orig-win))) (window-list))))
  (when (< emacs-major-version 25)
    (unless dont-redraw (redraw-frame))))

