From 1610cd32b2c39070229fae44b8f925dce20f74e8 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 6 Dec 2018 17:52:12 -0500 Subject: [PATCH] ui/popup: respect org-src-window-setup Added a new value for org-src-window-setup: 'popup-window Other values (like 'other-window) will revert to org's old behavior. Needs more testing. --- modules/ui/popup/+hacks.el | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/modules/ui/popup/+hacks.el b/modules/ui/popup/+hacks.el index 62644319d..c888b548f 100644 --- a/modules/ui/popup/+hacks.el +++ b/modules/ui/popup/+hacks.el @@ -231,6 +231,7 @@ the command buffer." ;; `org' (after! org + (defvar +popup--disable-internal nil) ;; Org has a scorched-earth window management system I'm not fond of. i.e. it ;; kills all windows and monopolizes the frame. No thanks. We can do better ;; ourselves. @@ -247,12 +248,12 @@ the command buffer." (defun +popup*org-src-pop-to-buffer (orig-fn buffer context) "Hand off the src-block window to the popup system by using `display-buffer' instead of switch-to-buffer-*." - (if (and (eq org-src-window-setup 'other-window) + (if (and (eq org-src-window-setup 'popup-window) +popup-mode) (pop-to-buffer buffer) (funcall orig-fn buffer context))) (advice-add #'org-src-switch-to-buffer :around #'+popup*org-src-pop-to-buffer) - (setq org-src-window-setup 'other-window) + (setq org-src-window-setup 'popup-window) ;; Ensure todo, agenda, and other minor popups are delegated to the popup system. (defun +popup*org-pop-to-buffer (orig-fn buf &optional norecord) @@ -266,7 +267,22 @@ instead of switch-to-buffer-*." (setq org-agenda-window-setup 'other-window org-agenda-restore-windows-after-quit nil) ;; Don't monopolize frame! - (advice-add #'org-agenda :around #'+popup*suppress-delete-other-windows)) + (defun +popup*org-agenda-suppress-delete-other-windows (orig-fn &rest args) + (cond ((not +popup-mode) + (apply orig-fn args)) + ((eq org-agenda-window-setup 'popup-window) + (let (org-agenda-restore-windows-after-quit) + (cl-letf (((symbol-function 'delete-other-windows) + (symbol-function 'ignore))) + (apply orig-fn args)))) + ((memq org-agenda-window-setup '(current-window other-window)) + (with-popup-rules! nil + (cl-letf (((symbol-function 'delete-other-windows) + (symbol-function 'ignore))) + (apply orig-fn args)))) + ((with-popup-rules! nil + (apply orig-fn args))))) + (advice-add #'org-agenda-prepare-window :around #'+popup*org-agenda-suppress-delete-other-windows)) ;; `persp-mode'