Hi All, First time contributing here, so apologies if I haven't gotten this quite right. As part of my employment I have an org document I have written contains a number of restclient and bash code blocks. The results of some of these src blocks are fed into other src blocks, and having to input "y" multiple times when trying to hit a REST api quickly became cumbersome. I also found the method of supplying a new org-confirm-babel-evaluate to disable the "ask to execute" behavior on a per language basis to be too crude. Therefore, I would like to introduce a new flag for src blocks ":confirm-evaluate", where a value of "n", "no", "f", or "false" will disable the "ask to execute" behavior for that specific block. I believe that this is a safer behavior compared to disabling "ask-to-execute" on a per language basis, and adds convenience to src blocks for literate programming. Thanks for your time, and I welcome any feedback!
Sincerely, Mack
From d05f12b3dc671065e29ebcd9cf5a10df00d1e5e9 Mon Sep 17 00:00:00 2001 From: Bligh <mackenziebligh@gmail.com> Date: Mon, 15 Jul 2019 17:28:00 -0700 Subject: [PATCH] ob-core.el: Add confirm-evaluate flag to src blocks * lisp/ (org-babel-execute-src-block): add a flag :confirm-evaluate that allows the org-babel-confirm-evaluate behaviour to be disabled on a per block basis, rather than only on a per language basis. TINYCHANGE --- lisp/ob-core.el | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index a4b2294d7..3167f165e 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -662,7 +662,17 @@ block." (let ((result (org-babel-read-result))) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result))) - ((org-babel-confirm-evaluate info) + ;; Use :confirm-evaluate flag to determine if a code block should ask the user to evaluate it + ((let* ((inputted (cdr (assq :confirm-evaluate params)))) + (if inputted + (let* ((inputted-confirm-evaluate (downcase inputted)) + (confirm-evaluate (not (or (string= "false" inputted-confirm-evaluate) + (string= "f" inputted-confirm-evaluate) + (string= "n" inputted-confirm-evaluate) + (string= "no" inputted-confirm-evaluate))))) + + (if confirm-evaluate (org-babel-confirm-evaluate info) "true")) + (org-babel-confirm-evaluate info))) (let* ((lang (nth 0 info)) (result-params (cdr (assq :result-params params))) ;; Expand noweb references in BODY and remove any -- 2.21.0