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.
This commit is contained in:
Henrik Lissner 2018-12-06 17:52:12 -05:00
parent 5c14fb42e0
commit 1610cd32b2
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -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'