From a0950e943236b67794754c1da74bb0b001d625ba Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Wed, 12 Jun 2024 12:47:48 +0200 Subject: [PATCH] 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 d1984b2d6..2e0e86f70 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))