emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] [PATCH] org-babel-execute-buffer: Prevent executing non-code blocks [9.6.20 ( @ /home/cassou/.emacs.d/lib/org/lisp/)]
@ 2024-03-09  7:42 Damien Cassou
  2024-03-12 12:18 ` Ihor Radchenko
  0 siblings, 1 reply; 9+ messages in thread
From: Damien Cassou @ 2024-03-09  7:42 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 884 bytes --]



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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-babel-execute-buffer-Prevent-executing-non-code-.patch --]
[-- Type: text/x-patch, Size: 1097 bytes --]

From 0879a7f4b855465a9cb1532293726a9a3d7d7c75 Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-03-17 14:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-09  7:42 [BUG] [PATCH] org-babel-execute-buffer: Prevent executing non-code blocks [9.6.20 ( @ /home/cassou/.emacs.d/lib/org/lisp/)] Damien Cassou
2024-03-12 12:18 ` Ihor Radchenko
2024-03-12 21:07   ` Damien Cassou
2024-03-12 21:23     ` Ihor Radchenko
2024-03-16 10:39       ` Damien Cassou
2024-03-16 11:48         ` Ihor Radchenko
2024-03-16 18:30           ` Damien Cassou
2024-03-17 12:28           ` Gerard Vermeulen
2024-03-17 14:30             ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).