From a3ebd8c669bac13c20c65c2df16dc295869bfba2 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Thu, 29 Feb 2024 15:01:00 +0300 Subject: [PATCH] org-babel-do-in-edit-buffer: When editing fails, do not throw an error * lisp/ob-core.el (org-babel-do-in-edit-buffer): Avoid throwing an error when something is not right with the code block. We already ignore errors when major mode fails to load and we generally don't want this macro to fail as it is used during indentation. Link: https://list.orgmode.org/orgmode/87wmqo3it5.fsf@localhost/ --- lisp/ob-core.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index bfeac257b..865dace5a 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -1192,11 +1192,14 @@ Return t if a code block was found at point, nil otherwise." ;; we want to restore this location after executing BODY. (outside-position (and (<= (line-beginning-position) - (org-element-post-affiliated element)) + (org-element-post-affiliated element)) (point-marker))) (org-src-window-setup 'switch-invisibly)) (when (and (org-babel-where-is-src-block-head element) - (org-edit-src-code)) + (condition-case nil + (org-edit-src-code) + (t (when outside-position (goto-char outside-position)) + nil))) (unwind-protect (progn ,@body) (org-edit-src-exit) (when outside-position (goto-char outside-position)))