diff --git a/modules/ui/popup/+hacks.el b/modules/ui/popup/+hacks.el index 4cc8f9e3d..7eefa7c7e 100644 --- a/modules/ui/popup/+hacks.el +++ b/modules/ui/popup/+hacks.el @@ -266,7 +266,18 @@ Ugh, such an ugly hack." :around #'org-switch-to-buffer-other-window (if +popup-mode (pop-to-buffer buf nil norecord) - (funcall orig-fn buf norecord)))) + (funcall orig-fn buf norecord))) + + ;; HACK `pop-to-buffer-same-window' consults `display-buffer-alist', which is + ;; what our popup manager uses to manage popup windows. However, + ;; `org-src-switch-to-buffer' already does its own window management + ;; prior to calling `pop-to-buffer-same-window', so there's no need to + ;; _then_ hand off the buffer to the pop up manager. + (defadvice! +popup--org-src-switch-to-buffer-a (orig-fn &rest args) + :around #'org-src-switch-to-buffer + (cl-letf (((symbol-function #'pop-to-buffer-same-window) + (symbol-function #'switch-to-buffer))) + (apply orig-fn args)))) ;;;###package persp-mode