From: Tom Gillespie <tgbugs@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] org-src: Add option to restore window configuration after edit
Date: Sun, 16 Feb 2020 19:50:33 -0800 [thread overview]
Message-ID: <CA+G3_POu2wu7uW0CiUBWd-x-SLR9cbLs70B6s+OO0uSLVV+9LQ@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 326 bytes --]
Hi all,
After hours of frustration ending in a realization that I should really
just read the change logs, I tracked down the reason why editing
source blocks was now destroying my window layout. I restored the
old behavior hidden behind a custom variable. Let me know if it looks
ok, or if more work is needed. Thanks!
Tom
[-- Attachment #2: 0001-org-src-Add-option-to-restore-window-configuration-a.patch --]
[-- Type: text/x-patch, Size: 2892 bytes --]
From 362a45ff172af3f49050964aa8534d11374934ca Mon Sep 17 00:00:00 2001
From: Tom Gillespie <tgbugs@gmail.com>
Date: Sun, 16 Feb 2020 19:21:16 -0800
Subject: [PATCH] org-src: Add option to restore window configuration after
edit
* lisp/org-src.el: Add an option to restore the previous window
configuration after exiting from editing a source block. The variable
is called `org-src-window-restore' and is only relevant when
`org-src-window-setup' is set to `reorganize-frame'.
This commit retains the default behavior in version 9.3 while
restoring the old behavior behind a custom variable, it
effectively reverts 819e98afd018cad3c13fd58bfcbd979ab36dfbc7
and adds an option to reenable the old behavior.
---
lisp/org-src.el | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/lisp/org-src.el b/lisp/org-src.el
index 7876deaba..f8f236ebd 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -169,6 +169,12 @@ other-frame Use `switch-to-buffer-other-frame' to display edit buffer.
(const other-window)
(const reorganize-frame)))
+(defcustom org-src-window-restore nil
+ "Non-nil means that org mode will restore the layout of the windows
+that was present before the org-src window was initially opened. This
+option is only involved if `org-src-window-setup' is set to
+`reorganize-frame'")
+
(defvar org-src-mode-hook nil
"Hook run after Org switched a source code snippet to its Emacs mode.
\\<org-mode-map>
@@ -276,6 +282,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 +478,9 @@ 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 (and (eq org-src-window-setup 'reorganize-frame)
+ org-src-window-restore)
+ (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,7 +1194,12 @@ 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 (and (eq org-src-window-setup 'reorganize-frame)
+ org-src-window-restore
+ 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
next reply other threads:[~2020-02-17 3:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-17 3:50 Tom Gillespie [this message]
2020-02-17 4:15 ` [PATCH] org-src: Add option to restore window configuration after edit Kyle Meyer
2020-02-17 5:27 ` Tom Gillespie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CA+G3_POu2wu7uW0CiUBWd-x-SLR9cbLs70B6s+OO0uSLVV+9LQ@mail.gmail.com \
--to=tgbugs@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).