summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Davison <davison@stats.ox.ac.uk>2009-11-07 20:45:50 -0500
committerDan Davison <davison@stats.ox.ac.uk>2009-11-09 17:05:07 -0500
commit081ff1ebe38facaafa3c13968de69f4cd64c2755 (patch)
tree9d7e57a9246f37afb954ba83de69f96aba4853da
parent9f6102f9e756e4f0d097eb2ee144ffe06c95ab87 (diff)
downloadorg-mode-081ff1ebe38facaafa3c13968de69f4cd64c2755.tar.gz
Avoid altering window configuration when saving edit buffer.
Saving the edit buffer is achieved by calling org-edit-src-exit, saving the org buffer and returning to the edit buffer with org-edit-src-code. When those two functions are used in this context, they should not attempt to restore the saved window configuration, nor alter the saved window configuration.
-rwxr-xr-xlisp/ChangeLog8
-rw-r--r--lisp/org-src.el19
2 files changed, 19 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0a87a4d..fdfe2c9 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2009-11-08 Dan Davison <davison@stats.ox.ac.uk>
+
+ * org-src.el (org-edit-src-code): New optional argument context
+ allows calling functions to avoid altering the saved window
+ configuration.
+ (org-edit-src-exit): Do not restore window configuration when this
+ function is used in the context of saving the edit buffer.
+
2009-11-09 Carsten Dominik <carsten.dominik@gmail.com>
* org-clock.el (org-clock-out, org-clock-cancel): Revert to
diff --git a/lisp/org-src.el b/lisp/org-src.el
index ed6607d..3a8d9ff 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -187,14 +187,16 @@ This minor mode is turned on in two situations:
There is a mode hook, and keybindings for `org-edit-src-exit' and
`org-edit-src-save'")
-(defun org-edit-src-code ()
+(defun org-edit-src-code (&optional context)
"Edit the source code example at point.
The example is copied to a separate buffer, and that buffer is switched
to the correct language mode. When done, exit with \\[org-edit-src-exit].
This will remove the original code in the Org buffer, and replace it with
-the edited version."
+the edited version. Optional argument CONTEXT is used by
+\\[org-edit-src-save] when calling this function."
(interactive)
- (setq org-edit-src-saved-temp-window-config (current-window-configuration))
+ (unless (eq context 'save)
+ (setq org-edit-src-saved-temp-window-config (current-window-configuration)))
(let ((line (org-current-line))
(col (current-column))
(case-fold-search t)
@@ -577,9 +579,10 @@ the language, a switch telling if the content should be in a single line."
(org-move-to-column (if preserve-indentation col (+ col total-nindent delta)))
(move-marker beg nil)
(move-marker end nil))
- (when org-edit-src-saved-temp-window-config
- (set-window-configuration org-edit-src-saved-temp-window-config)
- (setq org-edit-src-saved-temp-window-config nil)))
+ (unless (eq context 'save)
+ (when org-edit-src-saved-temp-window-config
+ (set-window-configuration org-edit-src-saved-temp-window-config)
+ (setq org-edit-src-saved-temp-window-config nil))))
(defun org-edit-src-save ()
"Save parent buffer with current state source-code buffer."
@@ -591,8 +594,8 @@ the language, a switch telling if the content should be in a single line."
(setq msg (current-message))
(if (eq org-src-window-setup 'other-frame)
(let ((org-src-window-setup 'current-window))
- (org-edit-src-code))
- (org-edit-src-code)))
+ (org-edit-src-code 'save))
+ (org-edit-src-code 'save)))
(push-mark m 'nomessage)
(goto-char (min p (point-max)))
(message (or msg ""))))