emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] org-babel: two confirmations for org/HTML "macro"?


From: Achim Gratz
Subject: Re: [O] org-babel: two confirmations for org/HTML "macro"?
Date: Wed, 10 Apr 2013 20:43:12 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Bastien writes:
>> I can understand the first question, but why the second?
>
> A mystery to me too, perhaps either Eric or Nicolas may explain.

That's because lob calls get wrapped internally in an anonymous
emacs-lisp source block that then feeds through the result from the
actual call as elisp.  The attached patch should suppress the
confirmation for the wrapper call.  To the best of my knowledge nothing
dangerous can happen with that evaluation and all confirmations for the
call stack down from there have already taken place according to the
users' setup.

Since the test suite doesn't really test confirmation at all, it would
be nice if someone with a good variety of Babel calls could check if the
number of confirmations stay the same with and without the patch.  I
don't think I have test cases that cover all possible combinations.

>From 7909cf5e52c2ab244c1b6ea67dada6e8a2eebb20 Mon Sep 17 00:00:00 2001
From: Achim Gratz <address@hidden>
Date: Wed, 10 Apr 2013 20:28:31 +0200
Subject: [PATCH] Babel: avoid superfluous confirmation for internal wrapper

* lisp/ob-exp.el (org-babel-exp-results): Suppress user confirmation
  of the emacs-lisp wrapper execution around a lob call.

* lisp/ob-lob.el (org-babel-lob-execute): Suppress user confirmation
  of the emacs-lisp wrapper execution around a lob call.
---
 lisp/ob-exp.el | 3 ++-
 lisp/ob-lob.el | 7 +++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el
index 0d98690..3c70e92 100644
--- a/lisp/ob-exp.el
+++ b/lisp/ob-exp.el
@@ -411,7 +411,8 @@ (defun org-babel-exp-results (info type &optional silent 
hash)
           ((equal type 'lob)
            (save-excursion
              (re-search-backward org-babel-lob-one-liner-regexp nil t)
-             (org-babel-execute-src-block nil info)))))))))
+             (let (org-confirm-babel-evaluate)
+               (org-babel-execute-src-block nil info))))))))))
 
 
 (provide 'ob-exp)
diff --git a/lisp/ob-lob.el b/lisp/ob-lob.el
index 4c89485..5366989 100644
--- a/lisp/ob-lob.el
+++ b/lisp/ob-lob.el
@@ -116,6 +116,7 @@ (defun org-babel-lob-get-info ()
         (list (length (if (= (length (match-string 12)) 0)
                           (match-string 2) (match-string 11)))))))))
 
+(defvar org-babel-default-header-args:emacs-lisp) ; dynamic binding from 
ob-emacs-lisp
 (defun org-babel-lob-execute (info)
   "Execute the lob call specified by INFO."
   (let* ((mkinfo (lambda (p) (list "emacs-lisp" "results" p nil nil (nth 2 
info))))
@@ -136,8 +137,10 @@ (defun org-babel-lob-execute (info)
        (save-excursion (goto-char (org-babel-where-is-src-block-result))
                        (forward-line 1)
                        (message "%S" (org-babel-read-result)))
-      (prog1 (org-babel-execute-src-block
-             nil (funcall mkinfo (org-babel-process-params pre-params)))
+      (prog1 (let* ((proc-params (org-babel-process-params pre-params))
+                    org-confirm-babel-evaluate)
+              (org-babel-execute-src-block
+               nil (funcall mkinfo proc-params)))
        ;; update the hash
        (when new-hash (org-babel-set-current-result-hash new-hash))))))
 
-- 
1.8.2.1


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Samples for the Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#BlofeldSamplesExtra

reply via email to

[Prev in Thread] Current Thread [Next in Thread]