summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-06-08 00:56:24 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-06-08 00:57:23 +0200
commit3b8037f316dd5147a09cfadd3bbb81e17a283b7c (patch)
treea2ef477c9a951f1be3106f261a74e6c29e51455c
parent51b743fc29412e9f61952f43adfd1b81e25470fb (diff)
downloadorg-mode-3b8037f316dd5147a09cfadd3bbb81e17a283b7c.tar.gz
org-src: Raise an error when source buffer is unreachable
* lisp/org-src.el (org-edit-src-exit): Raise an error when source buffer is unreachable.
-rw-r--r--lisp/org-src.el8
1 files changed, 5 insertions, 3 deletions
diff --git a/lisp/org-src.el b/lisp/org-src.el
index 8a81257..062f3b5 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -1065,8 +1065,10 @@ Throw an error if there is no such buffer."
(code (and write-back (org-src--contents-for-write-back))))
(set-buffer-modified-p nil)
;; Switch to source buffer. Kill sub-editing buffer.
- (let ((edit-buffer (current-buffer)))
- (org-src-switch-to-buffer (marker-buffer beg) 'exit)
+ (let ((edit-buffer (current-buffer))
+ (source-buffer (marker-buffer beg)))
+ (unless source-buffer (error "Source buffer disappeared. Aborting"))
+ (org-src-switch-to-buffer source-buffer 'exit)
(kill-buffer edit-buffer))
;; Insert modified code. Ensure it ends with a newline character.
(org-with-wide-buffer
@@ -1085,7 +1087,7 @@ Throw an error if there is no such buffer."
(cond
;; Block is hidden; move at start of block.
((cl-some (lambda (o) (eq (overlay-get o 'invisible) 'org-hide-block))
- (overlays-at (point)))
+ (overlays-at (point)))
(beginning-of-line 0))
(write-back (org-src--goto-coordinates coordinates beg end))))
;; Clean up left-over markers and restore window configuration.