Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

     https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.
------------------------------------------------------------------------

The command `org-babel-execute-buffer' tries to execute all source code
blocks of the current buffer. When it encounters a block that is not
executable the command crashes. The attached patch makes the command ignore
non-executable blocks and move on.

Emacs  : GNU Emacs 29.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.41, 
cairo version 1.18.0)
Package: Org mode version 9.6.20 ( @ /home/cassou/.emacs.d/lib/org/lisp/)
-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill
>From 0879a7f4b855465a9cb1532293726a9a3d7d7c75 Mon Sep 17 00:00:00 2001
From: Damien Cassou <dam...@cassou.me>
Date: Sat, 9 Mar 2024 08:35:44 +0100
Subject: [PATCH] org-babel-execute-buffer: Prevent executing non-code blocks

* lisp/ob-core.el (org-babel-execute-buffer): Guard against evaluating
non-code blocks.
---
 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 bfeac257b..ca7afcdc5 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -1417,7 +1417,11 @@ (defun org-babel-execute-buffer (&optional arg)
       (if (org-element-type-p
            (org-element-context) '(babel-call inline-babel-call))
           (org-babel-lob-execute-maybe)
-        (org-babel-execute-src-block arg)))))
+        (let* ((info (org-babel-get-src-block-info))
+               (lang (nth 0 info))
+               (cmd (intern (concat "org-babel-execute:" lang))))
+          (when (fboundp cmd)
+            (org-babel-execute-src-block arg)))))))
 
 ;;;###autoload
 (defun org-babel-execute-subtree (&optional arg)
-- 
2.43.1

Reply via email to