From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Kim <Richard.Kim1@synopsys.com> Subject: restore window configuration after org-edit-src-exit Date: Sat, 14 Dec 2019 11:06:44 -0800 Message-ID: <qtmfthmafqz.fsf@synopsys.com> Reply-To: Richard.Kim1@synopsys.com Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=-=-=" Return-path: <emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org> Received: from eggs.gnu.org ([2001:470:142:3::10]:45654) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <Richard.Kim1@synopsys.com>) id 1igF3A-0001Og-Uk for emacs-orgmode@gnu.org; Sat, 14 Dec 2019 16:34:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <Richard.Kim1@synopsys.com>) id 1igF37-0002DD-TH for emacs-orgmode@gnu.org; Sat, 14 Dec 2019 16:34:07 -0500 Received: from smtprelay-out1.synopsys.com ([149.117.73.133]:44538) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <Richard.Kim1@synopsys.com>) id 1igF37-00026W-9F for emacs-orgmode@gnu.org; Sat, 14 Dec 2019 16:34:05 -0500 Received: from mailhost.synopsys.com (sv2-mailhost2.synopsys.com [10.205.2.134]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id B342242394 for <emacs-orgmode@gnu.org>; Sat, 14 Dec 2019 19:06:45 +0000 (UTC) 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.org@gnu.org Sender: "Emacs-orgmode" <emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org> To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/html Content-Transfer-Encoding: quoted-printable <p> About a year ago change 819e98afd018cad3c13fd58bfcbd979ab36dfbc7 was checke= d in to remove code that restored window configuration when <code>org-edit-src-e= xit</code> finished. The net result is af if <code>C-x 1</code> is called to remove al= l windows except the org buffer just edited. This is very inconvenient. </p> <p> Why not call <code>winner-undo</code> to restore window configuration as sh= own here? </p> <div class=3D"org-src-container"> <pre class=3D"src src-diff"><span style=3D"color: #dddddd;">From</span><spa= n style=3D"color: #dc752f;"> </span><span style=3D"color: #dddddd;">bd0a2ab= aa8097338d7f33c7ca9a1d45f5da67e7a</span><span style=3D"color: #dc752f;"> </= span><span style=3D"color: #dddddd;">Mon</span><span style=3D"color: #dc752= f;"> </span><span style=3D"color: #dddddd;">Sep</span><span style=3D"color:= #dc752f;"> </span><span style=3D"color: #dddddd;">17</span><span style=3D"= color: #dc752f;"> </span><span style=3D"color: #dddddd;">00:00:00</span><sp= an style=3D"color: #dc752f;"> </span><span style=3D"color: #dddddd;">2001</= span> <span style=3D"color: #dddddd;">From:</span><span style=3D"color: #dc752f;"= > </span><span style=3D"color: #dddddd;">kimr</span><span style=3D"color: #= dc752f;"> </span><span style=3D"color: #dddddd;"><a href=3D"mailto:kimr%40s= ynopsys.com"><kimr@synopsys.com></a></span> <span style=3D"color: #dddddd;">Date:</span><span style=3D"color: #dc752f;"= > </span><span style=3D"color: #dddddd;">Sat,</span><span style=3D"color: #= dc752f;"> </span><span style=3D"color: #dddddd;">14</span><span style=3D"co= lor: #dc752f;"> </span><span style=3D"color: #dddddd;">Dec</span><span styl= e=3D"color: #dc752f;"> </span><span style=3D"color: #dddddd;">2019</span><s= pan style=3D"color: #dc752f;"> </span><span style=3D"color: #dddddd;">10:59= :00</span><span style=3D"color: #dc752f;"> </span><span style=3D"color: #dd= dddd;">-0800</span> <span style=3D"color: #dddddd;">Subject:</span><span style=3D"color: #dc752= f;"> </span><span style=3D"color: #dddddd;">[PATCH]</span><span style=3D"co= lor: #dc752f;"> </span><span style=3D"color: #dddddd;">restore</span><span = style=3D"color: #dc752f;"> </span><span style=3D"color: #dddddd;">window</s= pan><span style=3D"color: #dc752f;"> </span><span style=3D"color: #dddddd;"= >config</span><span style=3D"color: #dc752f;"> </span><span style=3D"color:= #dddddd;">by</span><span style=3D"color: #dc752f;"> </span><span style=3D"= color: #dddddd;">calling</span><span style=3D"color: #dc752f;"> </span><spa= n style=3D"color: #dddddd;">winner-undo</span> <span style=3D"color: #bc6ec5; background-color: #373040;">---</span> <span style=3D"color: #dc752f;"> </span><span style=3D"color: #dddddd;">lis= p/org-src.el</span><span style=3D"color: #dc752f;"> </span><span style=3D"c= olor: #dddddd;">|</span><span style=3D"color: #dc752f;"> </span><span style= =3D"color: #dddddd;">3</span><span style=3D"color: #dc752f;"> </span><span = style=3D"color: #dddddd;">++-</span> <span style=3D"color: #dc752f;"> </span><span style=3D"color: #dddddd;">1</= span><span style=3D"color: #dc752f;"> </span><span style=3D"color: #dddddd;= ">file</span><span style=3D"color: #dc752f;"> </span><span style=3D"color: = #dddddd;">changed,</span><span style=3D"color: #dc752f;"> </span><span styl= e=3D"color: #dddddd;">2</span><span style=3D"color: #dc752f;"> </span><span= style=3D"color: #dddddd;">insertions(+),</span><span style=3D"color: #dc75= 2f;"> </span><span style=3D"color: #dddddd;">1</span><span style=3D"color: = #dc752f;"> </span><span style=3D"color: #dddddd;">deletion(-)</span> <span style=3D"color: #dddddd;">diff</span><span style=3D"color: #dc752f;">= </span><span style=3D"color: #dddddd;">--git</span><span style=3D"color: #= dc752f;"> </span><span style=3D"color: #dddddd;">a/lisp/org-src.el</span><s= pan style=3D"color: #dc752f;"> </span><span style=3D"color: #dddddd;">b/lis= p/org-src.el</span> <span style=3D"color: #dddddd;">index</span><span style=3D"color: #dc752f;"= > </span><span style=3D"color: #dddddd;">5e50a1b4..c8c30889</span><span sty= le=3D"color: #dc752f;"> </span><span style=3D"color: #dddddd;">100644</span> <span style=3D"color: #bc6ec5; background-color: #373040;">---</span><span = style=3D"color: #dc752f;"> </span><span style=3D"color: #cbc1d5; background= -color: #373040;">a/lisp/org-src.el</span> <span style=3D"color: #bc6ec5; background-color: #373040;">+++</span><span = style=3D"color: #dc752f;"> </span><span style=3D"color: #cbc1d5; background= -color: #373040;">b/lisp/org-src.el</span> <span style=3D"color: #bc6ec5; background-color: #373040;">@@</span><span s= tyle=3D"color: #dc752f;"> </span><span style=3D"color: #bc6ec5; background-= color: #373040;">-1182,7</span><span style=3D"color: #dc752f;"> </span><spa= n style=3D"color: #bc6ec5; background-color: #373040;">+1182,8</span><span = style=3D"color: #dc752f;"> </span><span style=3D"color: #bc6ec5; background= -color: #373040;">@@</span><span style=3D"color: #dc752f;"> </span><span st= yle=3D"color: #bc6ec5; background-color: #373040;">Throw</span><span style= =3D"color: #dc752f;"> </span><span style=3D"color: #bc6ec5; background-colo= r: #373040;">an</span><span style=3D"color: #dc752f;"> </span><span style= =3D"color: #bc6ec5; background-color: #373040;">error</span><span style=3D"= color: #dc752f;"> </span><span style=3D"color: #bc6ec5; background-color: #= 373040;">if</span><span style=3D"color: #dc752f;"> </span><span style=3D"co= lor: #bc6ec5; background-color: #373040;">there</span><span style=3D"color:= #dc752f;"> </span><span style=3D"color: #bc6ec5; background-color: #373040= ;">is</span><span style=3D"color: #dc752f;"> </span><span style=3D"color: #= bc6ec5; background-color: #373040;">no</span><span style=3D"color: #dc752f;= "> </span><span style=3D"color: #bc6ec5; background-color: #373040;">such</= span><span style=3D"color: #dc752f;"> </span><span style=3D"color: #bc6ec5;= background-color: #373040;">buffer."</span> <span style=3D"color: #dc752f;"> </span><span style=3D"color: #ddddd= d;">(write-back</span><span style=3D"color: #dc752f;"> </span><span style= =3D"color: #dddddd;">(org-src--goto-coordinates</span><span style=3D"color:= #dc752f;"> </span><span style=3D"color: #dddddd;">coordinates</span><span = style=3D"color: #dc752f;"> </span><span style=3D"color: #dddddd;">beg</span= ><span style=3D"color: #dc752f;"> </span><span style=3D"color: #dddddd;">en= d))))</span> <span style=3D"color: #dc752f;"> </span><span style=3D"color: #dddddd;"= >;;</span><span style=3D"color: #dc752f;"> </span><span style=3D"color: #dd= dddd;">Clean</span><span style=3D"color: #dc752f;"> </span><span style=3D"c= olor: #dddddd;">up</span><span style=3D"color: #dc752f;"> </span><span styl= e=3D"color: #dddddd;">left-over</span><span style=3D"color: #dc752f;"> </sp= an><span style=3D"color: #dddddd;">markers</span><span style=3D"color: #dc7= 52f;"> </span><span style=3D"color: #dddddd;">and</span><span style=3D"colo= r: #dc752f;"> </span><span style=3D"color: #dddddd;">restore</span><span st= yle=3D"color: #dc752f;"> </span><span style=3D"color: #dddddd;">window</spa= n><span style=3D"color: #dc752f;"> </span><span style=3D"color: #dddddd;">c= onfiguration.</span> <span style=3D"color: #dc752f;"> </span><span style=3D"color: #dddddd;"= >(set-marker</span><span style=3D"color: #dc752f;"> </span><span style=3D"c= olor: #dddddd;">beg</span><span style=3D"color: #dc752f;"> </span><span sty= le=3D"color: #dddddd;">nil)</span> <span style=3D"color: #f2241f;">-</span><span style=3D"color: #dc752f;"> = </span><span style=3D"color: #f2241f;">(set-marker</span><span style=3D"co= lor: #dc752f;"> </span><span style=3D"color: #f2241f;">end</span><span styl= e=3D"color: #dc752f;"> </span><span style=3D"color: #f2241f;">nil)))</span> <span style=3D"color: #67b11d;">+</span><span style=3D"color: #dc752f;"> = </span><span style=3D"color: #67b11d;">(set-marker</span><span style=3D"co= lor: #dc752f;"> </span><span style=3D"color: #67b11d;">end</span><span styl= e=3D"color: #dc752f;"> </span><span style=3D"color: #67b11d;">nil)</span> <span style=3D"color: #67b11d;">+</span><span style=3D"color: #dc752f;"> = </span><span style=3D"color: #67b11d;">(winner-undo)))</span> <span style=3D"color: #dc752f;"> </span> <span style=3D"color: #dc752f;"> </span> <span style=3D"color: #dc752f;"> </span><span style=3D"color: #dddddd;">(pr= ovide</span><span style=3D"color: #dc752f;"> </span><span style=3D"color: #= dddddd;">'org-src)</span> <span style=3D"color: #f2241f;">-</span><span style=3D"color: #f2241f;">-</= span><span style=3D"color: #dc752f; background-color: #e0211d;"> </span> 2.22.1 </pre> </div> <p> For now I'm using the following advice do the same thing. </p> <div class=3D"org-src-container"> <pre class=3D"src src-elisp"><span style=3D"color: #4f97d7;">(</span><span = style=3D"color: #4f97d7; font-weight: bold;">defadvice</span> <span style= =3D"color: #bc6ec5; font-weight: bold;">org-edit-src-exit</span> <span styl= e=3D"color: #bc6ec5;">(</span>after restore-window-config activate<span sty= le=3D"color: #bc6ec5;">)</span> <span style=3D"color: #bc6ec5;">(</span>winner-undo<span style=3D"color: = #bc6ec5;">)</span><span style=3D"color: #4f97d7;">)</span> </pre> </div> --=-=-=--