emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Damien Cassou <damien@cassou.me>
To: emacs-orgmode@gnu.org
Subject: [BUG] [PATCH] org-babel-execute-buffer: Prevent executing non-code blocks [9.6.20 ( @ /home/cassou/.emacs.d/lib/org/lisp/)]
Date: Sat, 09 Mar 2024 08:42:30 +0100	[thread overview]
Message-ID: <87zfv7kg0p.fsf@cassou.me> (raw)

[-- 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


             reply	other threads:[~2024-03-09  7:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-09  7:42 Damien Cassou [this message]
2024-03-12 12:18 ` [BUG] [PATCH] org-babel-execute-buffer: Prevent executing non-code blocks [9.6.20 ( @ /home/cassou/.emacs.d/lib/org/lisp/)] 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zfv7kg0p.fsf@cassou.me \
    --to=damien@cassou.me \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).