emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-babel: two confirmations for org/HTML "macro"?
@ 2013-03-28  9:35 Stefan Vollmar
  2013-04-10 12:53 ` Bastien
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Vollmar @ 2013-03-28  9:35 UTC (permalink / raw)
  To: Org Mode Mailing List

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

Hallo,

we currently use MACROs for adding http://microformats.org/wiki/hcard information to web pages we create from org sources. As these MACROs have 12+ arguments, this is an error prone and inelegant way of getting the desired result. Nicolas Goaziou suggested using a babel approach so we could have named arguments - obviously, this is a much better solution (thanks again, Nicolas!).

Here is a minimal example of the principle:

-- snip

#+name: html-ex1 
#+header: :var who="World"
#+BEGIN_SRC org :exports none
<p>Hallo $who</p>
#+END_SRC

* Simple HTML export
#+call: html-ex1(who="Stefan") :results html

-- snip

When exporting this code (new exporter), I need two confirmations:

Evaluate this org code block (html-ex1)...
Evaluate this emacs-lisp block...

I can understand the first question, but why the second?
What is the best way to safely "auto-confirm" for this simple application?

Many thanks in advance.

Warm regards,
 Stefan
-- 
Dr. Stefan Vollmar, Dipl.-Phys.
Head of IT group
Max-Planck-Institut für neurologische Forschung
Gleueler Str. 50, 50931 Köln, Germany
Tel.: +49-221-4726-213  FAX +49-221-4726-298
Tel.: +49-221-478-5713  Mobile: 0160-93874279
E-Mail: vollmar@nf.mpg.de   http://www.nf.mpg.de









[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 4409 bytes --]

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

* Re: org-babel: two confirmations for org/HTML "macro"?
  2013-03-28  9:35 org-babel: two confirmations for org/HTML "macro"? Stefan Vollmar
@ 2013-04-10 12:53 ` Bastien
  2013-04-10 18:43   ` Achim Gratz
  0 siblings, 1 reply; 8+ messages in thread
From: Bastien @ 2013-04-10 12:53 UTC (permalink / raw)
  To: Stefan Vollmar; +Cc: Org Mode Mailing List

Hi Stefan,

Stefan Vollmar <vollmar@nf.mpg.de> writes:

> When exporting this code (new exporter), I need two confirmations:
>
> Evaluate this org code block (html-ex1)...
> Evaluate this emacs-lisp block...
>
> I can understand the first question, but why the second?

A mystery to me too, perhaps either Eric or Nicolas may explain.

> What is the best way to safely "auto-confirm" for this simple
> application?

Setting `org-confirm-babel-evaluate' locally to nil?

HTH,

-- 
 Bastien

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

* Re: org-babel: two confirmations for org/HTML "macro"?
  2013-04-10 12:53 ` Bastien
@ 2013-04-10 18:43   ` Achim Gratz
  2013-04-10 23:34     ` Bastien
  0 siblings, 1 reply; 8+ messages in thread
From: Achim Gratz @ 2013-04-10 18:43 UTC (permalink / raw)
  To: emacs-orgmode

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

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Babel-avoid-superfluous-confirmation-for-internal-wr.patch --]
[-- Type: text/x-patch, Size: 2190 bytes --]

From 7909cf5e52c2ab244c1b6ea67dada6e8a2eebb20 Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko@Stromeko.DE>
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


[-- Attachment #3: Type: text/plain, Size: 186 bytes --]



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

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

* Re: org-babel: two confirmations for org/HTML "macro"?
  2013-04-10 18:43   ` Achim Gratz
@ 2013-04-10 23:34     ` Bastien
  2013-04-11  5:22       ` Achim Gratz
  0 siblings, 1 reply; 8+ messages in thread
From: Bastien @ 2013-04-10 23:34 UTC (permalink / raw)
  To: Achim Gratz; +Cc: emacs-orgmode

Hi Achim,

(Sorry, I pushed a fix for the compiler warning that your patch also
solves.)

Achim Gratz <Stromeko@nexgo.de> writes:

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

Please let's go and apply this, that's the best way to have more
people testing it.  Thanks!

-- 
 Bastien

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

* Re: org-babel: two confirmations for org/HTML "macro"?
  2013-04-10 23:34     ` Bastien
@ 2013-04-11  5:22       ` Achim Gratz
  2013-04-11  8:41         ` Bastien
  0 siblings, 1 reply; 8+ messages in thread
From: Achim Gratz @ 2013-04-11  5:22 UTC (permalink / raw)
  To: emacs-orgmode

Bastien writes:
> (Sorry, I pushed a fix for the compiler warning that your patch also
> solves.)

Not in master, though?

> Achim Gratz <Stromeko@nexgo.de> writes:
>
>> 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.
>
> Please let's go and apply this, that's the best way to have more
> people testing it.  Thanks!

Please wait for Eric to chime in.


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

Factory and User Sound Singles for Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds

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

* Re: org-babel: two confirmations for org/HTML "macro"?
  2013-04-11  5:22       ` Achim Gratz
@ 2013-04-11  8:41         ` Bastien
  2013-04-12 22:37           ` Eric Schulte
  0 siblings, 1 reply; 8+ messages in thread
From: Bastien @ 2013-04-11  8:41 UTC (permalink / raw)
  To: Achim Gratz; +Cc: emacs-orgmode, schulte eric

Hi Achim,

Achim Gratz <Stromeko@nexgo.de> writes:

> Bastien writes:
>> (Sorry, I pushed a fix for the compiler warning that your patch also
>> solves.)
>
> Not in master, though?

Yes -- pushed this morning.

>> Achim Gratz <Stromeko@nexgo.de> writes:
>>
>>> 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.
>>
>> Please let's go and apply this, that's the best way to have more
>> people testing it.  Thanks!
>
> Please wait for Eric to chime in.

All right.  Copying Eric for the heads-up.

Thanks,

-- 
 Bastien

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

* Re: org-babel: two confirmations for org/HTML "macro"?
  2013-04-11  8:41         ` Bastien
@ 2013-04-12 22:37           ` Eric Schulte
  2013-04-13  6:37             ` Achim Gratz
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Schulte @ 2013-04-12 22:37 UTC (permalink / raw)
  To: Bastien; +Cc: Achim Gratz, emacs-orgmode

Bastien <bzg@gnu.org> writes:

> Hi Achim,
>
> Achim Gratz <Stromeko@nexgo.de> writes:
>
>> Bastien writes:
>>> (Sorry, I pushed a fix for the compiler warning that your patch also
>>> solves.)
>>
>> Not in master, though?
>
> Yes -- pushed this morning.
>
>>> Achim Gratz <Stromeko@nexgo.de> writes:
>>>
>>>> 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.
>>>
>>> Please let's go and apply this, that's the best way to have more
>>> people testing it.  Thanks!
>>
>> Please wait for Eric to chime in.
>
> All right.  Copying Eric for the heads-up.
>

After walking through this patch, it looks like it provides exactly the
correct behavior.  Please go ahead and apply these changes.

Thanks Achim for the patch!

-- 
Eric Schulte
http://cs.unm.edu/~eschulte

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

* Re: org-babel: two confirmations for org/HTML "macro"?
  2013-04-12 22:37           ` Eric Schulte
@ 2013-04-13  6:37             ` Achim Gratz
  0 siblings, 0 replies; 8+ messages in thread
From: Achim Gratz @ 2013-04-13  6:37 UTC (permalink / raw)
  To: emacs-orgmode

Eric Schulte writes:
> After walking through this patch, it looks like it provides exactly
> the correct behavior.  Please go ahead and apply these changes.

Thanks for checking, pushed to master.


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

Wavetables for the Terratec KOMPLEXER:
http://Synth.Stromeko.net/Downloads.html#KomplexerWaves

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

end of thread, other threads:[~2013-04-13  6:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-28  9:35 org-babel: two confirmations for org/HTML "macro"? Stefan Vollmar
2013-04-10 12:53 ` Bastien
2013-04-10 18:43   ` Achim Gratz
2013-04-10 23:34     ` Bastien
2013-04-11  5:22       ` Achim Gratz
2013-04-11  8:41         ` Bastien
2013-04-12 22:37           ` Eric Schulte
2013-04-13  6:37             ` Achim Gratz

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).