     (let ((last (current-buffer)))
       (cond ((when-let (dest (doom-buffers-in-mode
                               'magit-mode
-                              (cl-remove-if (lambda (buf) (eq buf last))
-                                            (mapcar #'car (window-prev-buffers)))
+                              (cl-loop for buf in (window-prev-buffers)
+                                       unless (eq (car buf) last)
+                                       collect (car buf))
                               t))
                (doom-popup-switch-to-buffer (car dest)))
              (kill-buffer last))

      ;; Don't monopolize frame!
      (advice-add #'org-agenda :around #'doom*suppress-delete-other-windows)

      (after! evil
        (map! :map* org-agenda-mode-map
              :m [escape] 'org-agenda-Quit
              :m "ESC"    'org-agenda-Quit))
      (let ((map org-agenda-mode-map))
        (define-key map "q" 'org-agenda-Quit)
        (define-key map "Q" 'org-agenda-Quit)))))

               (setq-local doom--modeline-format (doom-modeline modeline))
               (when doom--modeline-format
                 (doom-hide-modeline-mode +1)))))
    (when doom-hide-modeline-mode
      (doom-hide-modeline-mode -1))))
(add-hook 'doom-popup-mode-hook #'doom|hide-modeline-in-popup)

;;
(defun doom*popup-init (orig-fn &rest args)
