> I suppose that to some degree [*] the main benefit of this patch is that > it offers an option that calls quit-restore-window.
Yes, I agree with this. Setting org-src-window-setup to other-window was almost good enough for me -- it even respected display-buffer-base-action -- except that it wouldn't close the popped up window. > And that makes me think that the current options that go through a > simple display-buffer-based call (current-window and other-window) would > benefit from calling quit-restore-window like your `plain` option does. > If you agree, perhaps it's worth adding another patch on top that does > that. I agree other-window would benefit from quit-restore-window, it makes sense to close the existing window if it's been popped up. I'm less sure about current-window. We could certainly call quit-restore-window here, but I'm not sure there's any benefit, as it shouldn't open new windows that need to be closed (unless you're modifying display-buffer-alist, in which case the `plain' option should be preferred anyways). I'm also hesitant because Samuel relies on this option for accessibility reasons, and if I accidentally introduced a bug, I might not immediately notice, since I don't use this option. I've attached a patch on top of my previous one, calling quit-restore-window when using other-window, but leaving current-window alone. > Hmm, weird. I tried again (Emacs 26.3, vanilla config) and still see > the behavior I reported. Oh well. I tested again, with "emacs -q" this time, and got the behavior you reported. So it must be something with my config.
>From 0db0adc4f20d8c664976b89cbe033f5579e1fdc5 Mon Sep 17 00:00:00 2001 From: Jack Kamm <jackk...@gmail.com> Date: Tue, 21 Jan 2020 20:39:14 -0800 Subject: [PATCH] org-src: Add call to quit-restore-window in org-src-switch-to-buffer * lisp/org-src.el (org-src-switch-to-buffer): Add call to quit-restore-window in org-src-switch-to-buffer when org-src-window-setup is other-window --- lisp/org-src.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/org-src.el b/lisp/org-src.el index 52e99cf04..bb1c57c65 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -809,7 +809,9 @@ Raise an error when current buffer is not a source editing buffer." (pop-to-buffer buffer)) (`current-window (pop-to-buffer-same-window buffer)) (`other-window - (switch-to-buffer-other-window buffer)) + (let ((cur-win (selected-window))) + (switch-to-buffer-other-window buffer) + (when (eq context 'exit) (quit-restore-window cur-win)))) (`split-window-below (if (eq context 'exit) (delete-window) -- 2.25.0