all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* restore window configuration after org-edit-src-exit
@ 2019-12-14 19:06 Richard Kim
  2019-12-16 16:30 ` Nicolas Goaziou
  0 siblings, 1 reply; 16+ messages in thread
From: Richard Kim @ 2019-12-14 19:06 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1318 bytes --]

About a year ago change 819e98afd018cad3c13fd58bfcbd979ab36dfbc7 was checked in
to remove code that restored window configuration when =org-edit-src-exit=
finished. The net result is af if =C-x 1= is called to remove all windows except
the org buffer just edited. This is very inconvenient.

Why not call =winner-undo= to restore window configuration as shown here?

#+begin_src diff
From bd0a2abaa8097338d7f33c7ca9a1d45f5da67e7a Mon Sep 17 00:00:00 2001
From: kimr <kimr@synopsys.com>
Date: Sat, 14 Dec 2019 10:59:00 -0800
Subject: [PATCH] restore window config by calling winner-undo

---
 lisp/org-src.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index 5e50a1b4..c8c30889 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -1182,7 +1182,8 @@ Throw an error if there is no such buffer."
        (write-back (org-src--goto-coordinates coordinates beg end))))
     ;; Clean up left-over markers and restore window configuration.
     (set-marker beg nil)
-    (set-marker end nil)))
+    (set-marker end nil)
+    (winner-undo)))
 
 
 (provide 'org-src)
-- 
2.22.1
#+end_src


For now I'm using the following advice do the same thing.


#+begin_src elisp
(defadvice org-edit-src-exit (after restore-window-config activate)
  (winner-undo))
#+end_src




[-- Attachment #2: Type: text/html, Size: 8774 bytes --]

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: restore window configuration after org-edit-src-exit
  2019-12-14 19:06 restore window configuration after org-edit-src-exit Richard Kim
@ 2019-12-16 16:30 ` Nicolas Goaziou
  2019-12-17  1:51   ` Kyle Meyer
  0 siblings, 1 reply; 16+ messages in thread
From: Nicolas Goaziou @ 2019-12-16 16:30 UTC (permalink / raw)
  To: Richard Kim; +Cc: emacs-orgmode

Hello,

Richard Kim <Richard.Kim1@synopsys.com> writes:

> About a year ago change 819e98afd018cad3c13fd58bfcbd979ab36dfbc7 was checked in
> to remove code that restored window configuration when =org-edit-src-exit=
> finished. The net result is af if =C-x 1= is called to remove all windows except
> the org buffer just edited. This is very inconvenient.
>
> Why not call =winner-undo= to restore window configuration as shown
> here?

I'd rather not add another dependency just for this. 

However, it doesn't mean the inconvenience shouldn't be fixed. I cannot
remember why 819e98afd018cad3c13fd58bfcbd979ab36dfbc7 was necessary. I'm
Cc'ing Matt Price.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: restore window configuration after org-edit-src-exit
  2019-12-16 16:30 ` Nicolas Goaziou
@ 2019-12-17  1:51   ` Kyle Meyer
  2019-12-17 14:11     ` Jack Kamm
  0 siblings, 1 reply; 16+ messages in thread
From: Kyle Meyer @ 2019-12-17  1:51 UTC (permalink / raw)
  To: Nicolas Goaziou, Richard Kim; +Cc: emacs-orgmode

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
> However, it doesn't mean the inconvenience shouldn't be fixed. I cannot
> remember why 819e98afd018cad3c13fd58bfcbd979ab36dfbc7 was necessary. I'm
> Cc'ing Matt Price.

Here's the related thread:

  https://lists.gnu.org/archive/html/emacs-orgmode/2018-11/msg00253.html

Summary: Matt had a case where he didn't want the window configuration
to be restored, so he proposed hiding the behavior behind an option.
You wondered whether we should just remove support for restoring the
window configuration and not bother with the option.  Nobody offered a
defense for restoring the window configuration or complained... until
now :]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: restore window configuration after org-edit-src-exit
  2019-12-17  1:51   ` Kyle Meyer
@ 2019-12-17 14:11     ` Jack Kamm
  2019-12-17 14:28       ` Jack Kamm
  0 siblings, 1 reply; 16+ messages in thread
From: Jack Kamm @ 2019-12-17 14:11 UTC (permalink / raw)
  To: Kyle Meyer, Nicolas Goaziou, Richard Kim; +Cc: emacs-orgmode

I'd like to add a vote for the old behavior. I only recently noticed the
new behavior, and agree with Richard that it's inconvenient. I think
many of us missed this change because it wasn't in 9.2.

In particular, I'd propose to make the old behavior the default, and
hide the new behavior behind an option like Matt originally proposed.

I'm updating my copyright papers for my current job, if no one has
submitted a patch by the time I've got that sorted, I could work on a
patch then.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: restore window configuration after org-edit-src-exit
  2019-12-17 14:11     ` Jack Kamm
@ 2019-12-17 14:28       ` Jack Kamm
  2019-12-17 15:16         ` Fraga, Eric
  2019-12-22 14:45         ` Nicolas Goaziou
  0 siblings, 2 replies; 16+ messages in thread
From: Jack Kamm @ 2019-12-17 14:28 UTC (permalink / raw)
  To: Kyle Meyer, Nicolas Goaziou, Richard Kim; +Cc: emacs-orgmode

Sorry for the noise, but I just had another thought:

Rather than adding a new option, how about we make the behavior
dependent on the value of org-src-window-setup?

Basically, when org-src-window-setup is current-window, it never makes
sense to restore the original layout. But when org-src-window-setup is
reorganize-frame (the default), it always makes sense to restore the
original layout.

I'm not sure what the "correct" behavior would be for the other options
however.

Now that I think about it, I remember trying out the "current-window"
option before, and having a very similar experience to Matt -- while I
enjoyed having more manual control over the window layout, the fact that
org-mode would change the window layout after I finished editing
defeated the whole purpose of this, so I switched back to the original
defaults.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: restore window configuration after org-edit-src-exit
  2019-12-17 14:28       ` Jack Kamm
@ 2019-12-17 15:16         ` Fraga, Eric
  2019-12-22 14:45         ` Nicolas Goaziou
  1 sibling, 0 replies; 16+ messages in thread
From: Fraga, Eric @ 2019-12-17 15:16 UTC (permalink / raw)
  To: Jack Kamm; +Cc: emacs-orgmode@gnu.org, Nicolas Goaziou, Richard Kim

On Tuesday, 17 Dec 2019 at 06:28, Jack Kamm wrote:
> Basically, when org-src-window-setup is current-window, it never makes
> sense to restore the original layout. But when org-src-window-setup is
> reorganize-frame (the default), it always makes sense to restore the
> original layout.

This makes sense to me.

While we're talking about org-src-window-setup, I set it to
'split-window-right on my large monitor.  Sometimes, I make the src
window full frame but then, when trying to go back to the org buffer
(C-c '), I get the error:

delete-window: Attempt to delete minibuffer or sole ordinary window

This would be fixed if the original layout were restored instead of
simply deleting the src window, I guess.

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.3-34-g2eee3c

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: restore window configuration after org-edit-src-exit
  2019-12-17 14:28       ` Jack Kamm
  2019-12-17 15:16         ` Fraga, Eric
@ 2019-12-22 14:45         ` Nicolas Goaziou
  2019-12-23  1:46           ` Jack Kamm
  1 sibling, 1 reply; 16+ messages in thread
From: Nicolas Goaziou @ 2019-12-22 14:45 UTC (permalink / raw)
  To: Jack Kamm; +Cc: emacs-orgmode, Richard Kim

Hello,

Jack Kamm <jackkamm@gmail.com> writes:

> Rather than adding a new option, how about we make the behavior
> dependent on the value of org-src-window-setup?
>
> Basically, when org-src-window-setup is current-window, it never makes
> sense to restore the original layout. But when org-src-window-setup is
> reorganize-frame (the default), it always makes sense to restore the
> original layout.
>
> I'm not sure what the "correct" behavior would be for the other options
> however.

I think any value that modifies the current layout ought to restore it:
- `split-window-below'
- `split-window-right'
- `reorganize-frame'

OTOH, values that use the current layout should not restore it
afterwards:
- `current-window'
- `other-window'
- `other-frame'

This should be mentioned in the docstring.

WDYT?

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: restore window configuration after org-edit-src-exit
  2019-12-22 14:45         ` Nicolas Goaziou
@ 2019-12-23  1:46           ` Jack Kamm
  2019-12-23  8:17             ` Nicolas Goaziou
  0 siblings, 1 reply; 16+ messages in thread
From: Jack Kamm @ 2019-12-23  1:46 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode, Richard Kim

Hi,

> I think any value that modifies the current layout ought to restore it:
> - `split-window-below'
> - `split-window-right'
> - `reorganize-frame'
>
> OTOH, values that use the current layout should not restore it
> afterwards:
> - `current-window'
> - `other-window'
> - `other-frame'
>
> This should be mentioned in the docstring.
>
> WDYT?

I agree, this sounds like the correct behavior to me.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: restore window configuration after org-edit-src-exit
  2019-12-23  1:46           ` Jack Kamm
@ 2019-12-23  8:17             ` Nicolas Goaziou
  2019-12-23 17:15               ` Jack Kamm
  0 siblings, 1 reply; 16+ messages in thread
From: Nicolas Goaziou @ 2019-12-23  8:17 UTC (permalink / raw)
  To: Jack Kamm; +Cc: emacs-orgmode, Richard Kim

Hello,

Jack Kamm <jackkamm@gmail.com> writes:

> I agree, this sounds like the correct behavior to me.

OK. Would you want to implement it?

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: restore window configuration after org-edit-src-exit
  2019-12-23  8:17             ` Nicolas Goaziou
@ 2019-12-23 17:15               ` Jack Kamm
  2019-12-23 17:20                 ` Nicolas Goaziou
  0 siblings, 1 reply; 16+ messages in thread
From: Jack Kamm @ 2019-12-23 17:15 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode, Richard Kim

> OK. Would you want to implement it?

Yes, but I'm still in the process of updating my copyright papers for my
current job. My job said they won't be able to sign the copyright
disclaimer until the new year, so I expect this to be sorted out later
in January some time.

However, the change here is very small, I just wrote a small patch and
it's 15 insertions (+), 4 deletions(-), including the entry in
ORG-NEWS. My understanding is that such small changes don't require
explicit copyright assignment.

Is it OK for me to send the patch along, or should I hold off on this?

--Jack

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: restore window configuration after org-edit-src-exit
  2019-12-23 17:15               ` Jack Kamm
@ 2019-12-23 17:20                 ` Nicolas Goaziou
  2019-12-23 18:18                   ` [PATCH] " Jack Kamm
  0 siblings, 1 reply; 16+ messages in thread
From: Nicolas Goaziou @ 2019-12-23 17:20 UTC (permalink / raw)
  To: Jack Kamm; +Cc: emacs-orgmode, Richard Kim

Jack Kamm <jackkamm@gmail.com> writes:

> However, the change here is very small, I just wrote a small patch and
> it's 15 insertions (+), 4 deletions(-), including the entry in
> ORG-NEWS. My understanding is that such small changes don't require
> explicit copyright assignment.
>
> Is it OK for me to send the patch along, or should I hold off on this?

It is OK.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH] restore window configuration after org-edit-src-exit
  2019-12-23 17:20                 ` Nicolas Goaziou
@ 2019-12-23 18:18                   ` Jack Kamm
  2020-01-07  8:49                     ` Nicolas Goaziou
  0 siblings, 1 reply; 16+ messages in thread
From: Jack Kamm @ 2019-12-23 18:18 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode, Richard Kim

[-- Attachment #1: Type: text/plain, Size: 345 bytes --]

Attached is a patch to restore the window configuration after exiting an
org source buffer, when org-src-window-setup is one of reorganize-frame,
split-window-below, or split-window-right.

References:
https://lists.gnu.org/archive/html/emacs-orgmode/2019-12/msg00263.html
https://lists.gnu.org/archive/html/emacs-orgmode/2018-11/msg00253.html


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-src-restore-windows-for-some-values-of-org-src-w.patch --]
[-- Type: text/x-patch, Size: 3144 bytes --]

From 03a2b9433f1ad15ac21a49e7f0c6c5390e9e4375 Mon Sep 17 00:00:00 2001
From: Jack Kamm <jackkamm@gmail.com>
Date: Mon, 23 Dec 2019 08:55:55 -0800
Subject: [PATCH] org-src: restore windows for some values of
 org-src-window-setup

---
 etc/ORG-NEWS    |  3 +++
 lisp/org-src.el | 16 ++++++++++++----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 44dfd5459..8cb611aee 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -24,6 +24,9 @@ for all headlines.
 *** New option to group captured datetime entries by month
 A new `:tree-type month' option was added to org-capture-templates to
 group new datetime entries by month.
+*** Refinement in window behavior on exiting Org source buffer
+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 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 5e50a1b47..5a2f07d53 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -156,8 +156,7 @@ split-window-right Show edit buffer to the right of the current window,
                    keeping all other windows.
 other-window       Use `switch-to-buffer-other-window' to display edit buffer.
 reorganize-frame   Show only two windows on the current frame, the current
-                   window and the edit buffer.  When exiting the edit buffer,
-                   return to one window.
+                   window and the edit buffer.
 other-frame        Use `switch-to-buffer-other-frame' to display edit buffer.
                    Also, when exiting the edit buffer, kill that frame."
   :group 'org-edit-structure
@@ -276,6 +275,9 @@ issued in the language major mode buffer."
 (defvar-local org-src--remote nil)
 (put 'org-src--remote 'permanent-local t)
 
+(defvar-local org-src--saved-temp-window-config nil)
+(put 'org-src--saved-temp-window-config 'permanent-local t)
+
 (defvar-local org-src--source-type nil
   "Type of element being edited, as a symbol.")
 (put 'org-src--source-type 'permanent-local t)
@@ -469,6 +471,10 @@ When REMOTE is non-nil, do not try to preserve point or mark when
 moving from the edit area to the source.
 
 Leave point in edit buffer."
+  (when (memq org-src-window-setup '(reorganize-frame
+				     split-window-below
+				     split-window-right))
+    (setq org-src--saved-temp-window-config (current-window-configuration)))
   (let* ((area (org-src--contents-area datum))
 	 (beg (copy-marker (nth 0 area)))
 	 (end (copy-marker (nth 1 area) t))
@@ -1182,8 +1188,10 @@ Throw an error if there is no such buffer."
        (write-back (org-src--goto-coordinates coordinates beg end))))
     ;; Clean up left-over markers and restore window configuration.
     (set-marker beg nil)
-    (set-marker end nil)))
-
+    (set-marker end nil)
+    (when org-src--saved-temp-window-config
+      (set-window-configuration org-src--saved-temp-window-config)
+      (setq org-src--saved-temp-window-config nil))))
 
 (provide 'org-src)
 
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH] restore window configuration after org-edit-src-exit
  2019-12-23 18:18                   ` [PATCH] " Jack Kamm
@ 2020-01-07  8:49                     ` Nicolas Goaziou
  2020-01-09 15:03                       ` Matt Price
  2020-01-09 17:43                       ` Jack Kamm
  0 siblings, 2 replies; 16+ messages in thread
From: Nicolas Goaziou @ 2020-01-07  8:49 UTC (permalink / raw)
  To: Jack Kamm; +Cc: emacs-orgmode, Richard Kim

Hello,

Jack Kamm <jackkamm@gmail.com> writes:

> Attached is a patch to restore the window configuration after exiting an
> org source buffer, when org-src-window-setup is one of reorganize-frame,
> split-window-below, or split-window-right.

Thank you for the patch! Some comments follow.

> @@ -156,8 +156,7 @@ split-window-right Show edit buffer to the right of the current window,
>                     keeping all other windows.
>  other-window       Use `switch-to-buffer-other-window' to display edit buffer.
>  reorganize-frame   Show only two windows on the current frame, the current
> -                   window and the edit buffer.  When exiting the edit buffer,
> -                   return to one window.
> +                   window and the edit buffer.
>  other-frame        Use `switch-to-buffer-other-frame' to display edit buffer.
>                     Also, when exiting the edit buffer, kill that
>                     frame."

It would be useful to also explain what happens when the value is
`reorganize-frame', `split-window-right', or `split-window-right', e.g.,
that previous window configuration is restored.

> +    (when org-src--saved-temp-window-config
> +      (set-window-configuration org-src--saved-temp-window-config)
> +      (setq org-src--saved-temp-window-config nil))))

It may be useful to wrap `set-window-configuration' within
`unwind-protect' so we can still reset the
`org-src--saved-temp-window-config' variable even though something went
wrong.

WDYT?

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] restore window configuration after org-edit-src-exit
  2020-01-07  8:49                     ` Nicolas Goaziou
@ 2020-01-09 15:03                       ` Matt Price
  2020-01-09 17:43                       ` Jack Kamm
  1 sibling, 0 replies; 16+ messages in thread
From: Matt Price @ 2020-01-09 15:03 UTC (permalink / raw)
  To: Jack Kamm, Org Mode, Richard Kim

[-- Attachment #1: Type: text/plain, Size: 1850 bytes --]

Hi, sorry I missed this thread in the peri-holiday rush, just want to say
thank you all for ironing out the difficulties arsing from that change
earlier.

On Tue, Jan 7, 2020 at 4:06 AM Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> Hello,
>
> Jack Kamm <jackkamm@gmail.com> writes:
>
> > Attached is a patch to restore the window configuration after exiting an
> > org source buffer, when org-src-window-setup is one of reorganize-frame,
> > split-window-below, or split-window-right.
>
> Thank you for the patch! Some comments follow.
>
> > @@ -156,8 +156,7 @@ split-window-right Show edit buffer to the right of
> the current window,
> >                     keeping all other windows.
> >  other-window       Use `switch-to-buffer-other-window' to display edit
> buffer.
> >  reorganize-frame   Show only two windows on the current frame, the
> current
> > -                   window and the edit buffer.  When exiting the edit
> buffer,
> > -                   return to one window.
> > +                   window and the edit buffer.
> >  other-frame        Use `switch-to-buffer-other-frame' to display edit
> buffer.
> >                     Also, when exiting the edit buffer, kill that
> >                     frame."
>
> It would be useful to also explain what happens when the value is
> `reorganize-frame', `split-window-right', or `split-window-right', e.g.,
> that previous window configuration is restored.
>
> > +    (when org-src--saved-temp-window-config
> > +      (set-window-configuration org-src--saved-temp-window-config)
> > +      (setq org-src--saved-temp-window-config nil))))
>
> It may be useful to wrap `set-window-configuration' within
> `unwind-protect' so we can still reset the
> `org-src--saved-temp-window-config' variable even though something went
> wrong.
>
> WDYT?
>
> Regards,
>
> --
> Nicolas Goaziou
>
>

[-- Attachment #2: Type: text/html, Size: 2492 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] restore window configuration after org-edit-src-exit
  2020-01-07  8:49                     ` Nicolas Goaziou
  2020-01-09 15:03                       ` Matt Price
@ 2020-01-09 17:43                       ` Jack Kamm
  2020-01-14 23:10                         ` Jack Kamm
  1 sibling, 1 reply; 16+ messages in thread
From: Jack Kamm @ 2020-01-09 17:43 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode, Richard Kim

[-- Attachment #1: Type: text/plain, Size: 1317 bytes --]

Hello,

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Thank you for the patch! Some comments follow.
>
> It would be useful to also explain what happens when the value is
> `reorganize-frame', `split-window-right', or `split-window-right', e.g.,
> that previous window configuration is restored.
>
> It may be useful to wrap `set-window-configuration' within
> `unwind-protect' so we can still reset the
> `org-src--saved-temp-window-config' variable even though something went
> wrong.
>
> WDYT?

Thank you for reviewing my patch, I agree with both of your suggestions,
and have added them to the attached patch, which I also rebased on
latest master.

I am wondering whether this should be considered a new feature, or
instead fixing a regression, in which case I could rebase on maint
instead.

Finally, I think we should consider moving to the display-buffer
framework
(https://www.gnu.org/software/emacs/manual/html_node/elisp/Choosing-Window.html#Choosing-Window),
as this will provide a lot more flexibility, and simplify the code as
well. We could also use `quit-restore-window'
(https://www.gnu.org/software/emacs/manual/html_node/elisp/Quitting-Windows.html)
to restore the window configuration after editing. I'll start a new
thread/RFC/patch for this later this month, when I have a bit more time.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-src-restore-windows-for-some-values-of-org-src-w.patch --]
[-- Type: text/x-patch, Size: 3395 bytes --]

From 8d1cf7500d69823bc4869248bbe251758d3dcdda Mon Sep 17 00:00:00 2001
From: Jack Kamm <jackkamm@gmail.com>
Date: Mon, 23 Dec 2019 08:55:55 -0800
Subject: [PATCH] org-src: restore windows for some values of
 org-src-window-setup

---
 etc/ORG-NEWS    |  5 +++++
 lisp/org-src.el | 22 +++++++++++++++++-----
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 0f836d946..67c3ca2ed 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -30,6 +30,11 @@ group new datetime entries by month.
 Babel Java blocks recognize header argument =:cmdargs= and pass its
 value in call to =java=.
 
+*** Refinement in window behavior on exiting Org source buffer
+
+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 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 7876deaba..878821b14 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -156,10 +156,12 @@ split-window-right Show edit buffer to the right of the current window,
                    keeping all other windows.
 other-window       Use `switch-to-buffer-other-window' to display edit buffer.
 reorganize-frame   Show only two windows on the current frame, the current
-                   window and the edit buffer.  When exiting the edit buffer,
-                   return to one window.
+                   window and the edit buffer.
 other-frame        Use `switch-to-buffer-other-frame' to display edit buffer.
-                   Also, when exiting the edit buffer, kill that frame."
+                   Also, when exiting the edit buffer, kill that frame.
+
+Values that modify the window layout (reorganize-frame, split-window-below,
+split-window-right) will restore the layout after exiting the edit buffer."
   :group 'org-edit-structure
   :type '(choice
 	  (const current-window)
@@ -276,6 +278,9 @@ issued in the language major mode buffer."
 (defvar-local org-src--remote nil)
 (put 'org-src--remote 'permanent-local t)
 
+(defvar-local org-src--saved-temp-window-config nil)
+(put 'org-src--saved-temp-window-config 'permanent-local t)
+
 (defvar-local org-src--source-type nil
   "Type of element being edited, as a symbol.")
 (put 'org-src--source-type 'permanent-local t)
@@ -469,6 +474,10 @@ When REMOTE is non-nil, do not try to preserve point or mark when
 moving from the edit area to the source.
 
 Leave point in edit buffer."
+  (when (memq org-src-window-setup '(reorganize-frame
+				     split-window-below
+				     split-window-right))
+    (setq org-src--saved-temp-window-config (current-window-configuration)))
   (let* ((area (org-src--contents-area datum))
 	 (beg (copy-marker (nth 0 area)))
 	 (end (copy-marker (nth 1 area) t))
@@ -1182,8 +1191,11 @@ Throw an error if there is no such buffer."
        (write-back (org-src--goto-coordinates coordinates beg end))))
     ;; Clean up left-over markers and restore window configuration.
     (set-marker beg nil)
-    (set-marker end nil)))
-
+    (set-marker end nil)
+    (when org-src--saved-temp-window-config
+      (unwind-protect
+	  (set-window-configuration org-src--saved-temp-window-config)
+	(setq org-src--saved-temp-window-config nil)))))
 
 (provide 'org-src)
 
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH] restore window configuration after org-edit-src-exit
  2020-01-09 17:43                       ` Jack Kamm
@ 2020-01-14 23:10                         ` Jack Kamm
  0 siblings, 0 replies; 16+ messages in thread
From: Jack Kamm @ 2020-01-14 23:10 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode, Richard Kim

By the way -- I just got my copyright papers officially updated for my
current job -- so we don't need to worry about line counts and whatnot
anymore :)

Best,
John "Jack" Kamm

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2020-01-14 23:10 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-14 19:06 restore window configuration after org-edit-src-exit Richard Kim
2019-12-16 16:30 ` Nicolas Goaziou
2019-12-17  1:51   ` Kyle Meyer
2019-12-17 14:11     ` Jack Kamm
2019-12-17 14:28       ` Jack Kamm
2019-12-17 15:16         ` Fraga, Eric
2019-12-22 14:45         ` Nicolas Goaziou
2019-12-23  1:46           ` Jack Kamm
2019-12-23  8:17             ` Nicolas Goaziou
2019-12-23 17:15               ` Jack Kamm
2019-12-23 17:20                 ` Nicolas Goaziou
2019-12-23 18:18                   ` [PATCH] " Jack Kamm
2020-01-07  8:49                     ` Nicolas Goaziou
2020-01-09 15:03                       ` Matt Price
2020-01-09 17:43                       ` Jack Kamm
2020-01-14 23:10                         ` Jack Kamm

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.