From 5f5db3d35304ee95d92d1370669132a34513fb7a Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Mon, 4 Mar 2024 13:10:17 +0300 Subject: [PATCH] org-babel-do-in-edit-buffer: Fix when opening src edit buffer fails * lisp/ob-core.el (org-babel-do-in-edit-buffer): When opening src edit buffer fails, do not leave point inside that buffer. Reported-by: gerard.vermeulen@posteo.net Link: https://orgmode.org/list/5bf6832d2485f0aa6be2e5ea2eba37d2@posteo.net --- lisp/ob-core.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 865dace5a..cc257a3b3 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -1198,8 +1198,10 @@ Return t if a code block was found at point, nil otherwise." (when (and (org-babel-where-is-src-block-head element) (condition-case nil (org-edit-src-code) - (t (when outside-position (goto-char outside-position)) - nil))) + (t + (org-edit-src-exit) + (when outside-position (goto-char outside-position)) + nil))) (unwind-protect (progn ,@body) (org-edit-src-exit) (when outside-position (goto-char outside-position)))