From mboxrd@z Thu Jan  1 00:00:00 1970
From: Jack Kamm <jackkamm@gmail.com>
Subject: Re: [RFC PATCH] Changes to pop-up source buffers
Date: Sun, 19 Jan 2020 09:13:28 -0800
Message-ID: <87a76jmksn.fsf@gmail.com>
References: <878sm4nn67.fsf@kyleam.com>
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Return-path: <emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org>
Received: from eggs.gnu.org ([2001:470:142:3::10]:53661)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <jackkamm@gmail.com>) id 1itE9Y-0004M5-7R
 for emacs-orgmode@gnu.org; Sun, 19 Jan 2020 12:14:25 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <jackkamm@gmail.com>) id 1itE9X-0001uH-0j
 for emacs-orgmode@gnu.org; Sun, 19 Jan 2020 12:14:24 -0500
Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]:51252)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <jackkamm@gmail.com>) id 1itE9W-0001tE-O5
 for emacs-orgmode@gnu.org; Sun, 19 Jan 2020 12:14:22 -0500
Received: by mail-pj1-x1042.google.com with SMTP id d15so5592890pjw.1
 for <emacs-orgmode@gnu.org>; Sun, 19 Jan 2020 09:14:22 -0800 (PST)
In-Reply-To: <878sm4nn67.fsf@kyleam.com>
List-Id: "General discussions about Org-mode." <emacs-orgmode.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/emacs-orgmode>
List-Post: <mailto:emacs-orgmode@gnu.org>
List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=subscribe>
Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org
Sender: "Emacs-orgmode"
 <emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org>
To: Kyle Meyer <kyle@kyleam.com>, emacs-orgmode@gnu.org

--=-=-=
Content-Type: text/plain

Hi Kyle,

Thanks for taking the time to do a thorough review of the patch, I found
your response (especially the many examples you included) to be very
illuminating.

I agree that relying more on display-buffer-based functions is good, but
in retrospect I may have been over-eager, especially since
reorganize-frame can't be switched over, and split-window-right might
require writing a new action function.

My main motivation was to use my own display-buffer configuration to
show the source buffer. So I've rewritten the patch to be smaller and
more conservative, just adding a "plain" option to org-src-window-setup,
and not changing the implementation of any existing options.  I think
this is less likely to disrupt existing workflows or introduce
accidental bugs.

What do you think of using this smaller patch instead?

As an aside, in case we do decide to re-implement some of the display
options, now or in future, I did have a slight discrepancy from the
behavior you describe for split-window-right:

> Quickly testing, this has a slight change in behavior.  If there is
> already a window below the current Org buffer window, the new source
> window will be popped up below the _other_ window rather than the Org
> buffer.  I think this could be fixed (and the code in general
> simplified) by using display-buffer-below-selected.

On my own system, the window pops up below the existing Org buffer, even
if I have several existing horizontal splits. I'm not sure why.


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0001-org-src-Add-option-plain-to-org-src-window-setup.patch

>From a9cb8889df25697ff73e7c1e72987dac01875c8a Mon Sep 17 00:00:00 2001
From: Jack Kamm <jackkamm@gmail.com>
Date: Sun, 19 Jan 2020 08:28:36 -0800
Subject: [PATCH] org-src: Add option 'plain to org-src-window-setup

* lisp/org-src.el (org-src-window-setup): Add option 'plain for
org-src-window-setup, that uses vanilla display-buffer to show the
source window.
---
 etc/ORG-NEWS    | 7 +++++++
 lisp/org-src.el | 6 ++++++
 2 files changed, 13 insertions(+)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 67c3ca2ed..b32d37e65 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -35,6 +35,13 @@ value in call to =java=.
 After editing a source block, Org will restore the window layout when
 ~org-src-window-setup~ is set to a value that modifies the layout.
 
+*** New option to show source buffers using "plain" display-buffer
+
+Added option ~'plain~ to ~org-src-window-setup~ to show source buffers
+using ~display-buffer~. This allows users to control how source
+buffers are displayed by modifying ~display-buffer-alist~ or
+~display-buffer-base-action~.
+
 ** New functions
 *** ~org-columns-toggle-or-columns-quit~
 =<C-c C-c>= bound to ~org-columns-toggle-or-columns-quit~ replaces the
diff --git a/lisp/org-src.el b/lisp/org-src.el
index 878821b14..52e99cf04 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -148,6 +148,9 @@ the existing edit buffer."
   "How the source code edit buffer should be displayed.
 Possible values for this option are:
 
+plain              Show edit buffer using `display-buffer'.  Users can
+                   further control the display behavior by modifying
+                   `display-buffer-alist' and its relatives.
 current-window     Show edit buffer in the current window, keeping all other
                    windows.
 split-window-below Show edit buffer below the current window, keeping all
@@ -801,6 +804,9 @@ Raise an error when current buffer is not a source editing buffer."
 
 (defun org-src-switch-to-buffer (buffer context)
   (pcase org-src-window-setup
+    (`plain
+     (when (eq context 'exit) (quit-restore-window))
+     (pop-to-buffer buffer))
     (`current-window (pop-to-buffer-same-window buffer))
     (`other-window
      (switch-to-buffer-other-window buffer))
-- 
2.25.0


--=-=-=--