branch: externals-release/org
commit a0950e943236b67794754c1da74bb0b001d625ba
Author: Ihor Radchenko <yanta...@posteo.net>
Commit: Ihor Radchenko <yanta...@posteo.net>

    org-babel-execute-src-block: Handle code block moving point
    
    * lisp/ob-core.el (org-babel-execute-src-block): Make sure that point
    remain on src block after evaluation.  The function logic later
    implicitly assumes that the point is on the block that has been
    evaluated.
---
 lisp/ob-core.el | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index d1984b2d6f..2e0e86f70c 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -893,7 +893,11 @@ guess will be made."
                          (format "at position %S" (nth 5 info)))))
            (setq exec-start-time (current-time)
                   result
-                 (let ((r (save-current-buffer (funcall cmd body params))))
+                 (let ((r
+                         ;; Code block may move point in the buffer.
+                         ;; Make sure that the point remains on the
+                         ;; code block.
+                         (save-excursion (funcall cmd body params))))
                    (if (and (eq (cdr (assq :result-type params)) 'value)
                             (or (member "vector" result-params)
                                 (member "table" result-params))

Reply via email to