summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-12-25 00:10:39 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-12-25 00:10:39 +0100
commitb3ddb051e667bdc2daf6e6d9ba4742a56b54d449 (patch)
tree813276fbc411bb6a563020297e347b58bc9a36c3
parentf4ae1941c90e578e914268891bceff5751fbfd70 (diff)
downloadorg-mode-b3ddb051e667bdc2daf6e6d9ba4742a56b54d449.tar.gz
ob-exp: Fix source blocks generated by other source blocks
* lisp/ob-exp.el (org-babel-exp--at-source): Source blocks generated by evaluating other source blocks may not be found in the original buffer. In that case, do not move point. Reported-by: "Berry, Charles" <ccberry@ucsd.edu> <http://lists.gnu.org/r/emacs-orgmode/2017-12/msg00538.html>
-rw-r--r--lisp/ob-exp.el8
1 files changed, 6 insertions, 2 deletions
diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el
index 9606d3e..0563d75 100644
--- a/lisp/ob-exp.el
+++ b/lisp/ob-exp.el
@@ -58,9 +58,13 @@ returned is the value of the last form in BODY. Assume that
point is at the beginning of the Babel block."
(declare (indent 1) (debug body))
`(let ((source (get-text-property (point) 'org-reference)))
- (with-current-buffer org-babel-exp-reference-buffer
+ ;; Source blocks created during export process (e.g., by other
+ ;; source blocks) are not referenced. In this case, do not move
+ ;; point at all.
+ (with-current-buffer (if source org-babel-exp-reference-buffer
+ (current-buffer))
(org-with-wide-buffer
- (goto-char source)
+ (when source (goto-char source))
,@body))))
(defun org-babel-exp-src-block ()