From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Girard Subject: Re: [Babel] org-babel-execute-buffer gives different results than org-babel-exp-non-block-elements Date: Fri, 23 Aug 2013 01:20:09 +0200 Message-ID: References: <87y57twot4.fsf@gmail.com> <87ppt5wjn1.fsf@gmail.com> <87siy1jpff.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=001a1133158e2ae73804e491899c Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57427) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCeB6-0005Wu-De for emacs-orgmode@gnu.org; Thu, 22 Aug 2013 19:20:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VCeB4-0008TQ-FQ for emacs-orgmode@gnu.org; Thu, 22 Aug 2013 19:20:32 -0400 Received: from mail-vb0-x229.google.com ([2607:f8b0:400c:c02::229]:36701) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCeB4-0008So-29 for emacs-orgmode@gnu.org; Thu, 22 Aug 2013 19:20:30 -0400 Received: by mail-vb0-f41.google.com with SMTP id g17so1787407vbg.14 for ; Thu, 22 Aug 2013 16:20:29 -0700 (PDT) In-Reply-To: <87siy1jpff.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nicolas Goaziou Cc: emacs-orgmode --001a1133158e2ae73804e491899c Content-Type: text/plain; charset=ISO-8859-1 2013/8/23 Nicolas Goaziou : > Nicolas Girard writes: > > I see. > > There is an important difference between evaluating a buffer and > evaluating a buffer during export. In the latter, Babel has to deal with > replacement values, i.e., code block is replaced by its results. See the > difference between `org-export-execute-babel-code' and > `org-babel-execute-buffer' in a buffer containing only > > src_emacs-lisp[:results raw]{(+ 1 2)} > > In this case, your code removes the code (and much more) as > a side-effect. This confuses `org-babel-exp-non-block-elements', which > also tries to remove it. As this fails, it removes a random part of the > buffer instead (probably as a mean revenge). > Thanks very much for your insight ! I came to the same conclusions and found a temporary solution, namely using the value (bufferp org-current-export-file) to check wether the code is called by the exporter or just Babel. Attached is a modified version of my code that behaves differently depending of the value of (bufferp org-current-export-file). Do you think it could be robust enough ? > `org-babel-exp-non-block-elements' and `org-babel-exp-process-buffer' > could probably check if code still exists before trying to remove (and > replace) it. > Yeah, I don't know how much work it would represent but it seems much more appropriate that my hack-ish solution. --- Nicolas --001a1133158e2ae73804e491899c Content-Type: application/octet-stream; name="transclusion.org" Content-Disposition: attachment; filename="transclusion.org" Content-Transfer-Encoding: base64 X-Attachment-Id: f_hkolebnd0 IytBVVRIT1I6IE5pY29sYXMgR2lyYXJkIDxnaXJhcmQubmljb2xhc0BnbWFpbC5jb20+CgoqIElu c3RydWN0aW9ucwo6UFJPUEVSVElFUzoKOlZJU0lCSUxJVFk6IGFsbAo6RU5EOgoKMS4gRXZhbHVh dGUgdGhlIGVsaXNwIGNvZGUgY29udGFpbmVkIGluIHRoZSBzZWN0aW9uICJDb2RlIHRvIGV2YWx1 YXRlIiwgZWl0aGVyIGJ5IGV4ZWN1dGluZyA9KG9yZy1iYWJlbC1sb2FkLWZpbGUgYnVmZmVyLWZp bGUtbmFtZSk9LCBvciBieSBldmFsdWF0aW5nIG1hbnVhbGx5IGVhY2ggZnVuY3Rpb24gdXNpbmcg PUMteCBDLWU9CjIuIFJ1biB0aGUgc21hbGwgdGVzdHMgY29udGFpbmVkIGluIHRoZSBzZWN0aW9u ICJUcmFuc2NsdXNpb24gdGVzdHMiIHVzaW5nID0ob3JnLWJhYmVsLWV4ZWN1dGUtYnVmZmVyKT0u IFRoaXMgd2lsbCBiZWhhdmUgYXMgZXhwZWN0ZWQKPShvcmctYmFiZWwtZXhwLXByb2Nlc3MtYnVm ZmVyKT0KMy4gUmVzdG9yZSB0aGUgYnVmZmVyIHRvIGl0cyBvcmlnaW5hbCBjb250ZW50cyB1c2lu ZyA9Qy1fPQo0LiBOb3csIHJ1biA9KHByb2duIChyZXF1aXJlICdveCkgKG9yZy1leHBvcnQtZXhl Y3V0ZS1iYWJlbC1jb2RlKSk9IGFuZCBjb21wYXJlIHdpdGggdGhlIGJlaGF2aW91ciBpbiBzdGVw ICgyLikKCiAgIFVsdGltYXRlbHkgdGhpcyBib2lscyBkb3duIHRvCiAgICMrQkVHSU5fU1JDIGVt YWNzLWxpc3AgOnRhbmdsZSBubwogICAgIChsZXQgKChyZWZlcmVuY2UgKG9yZy1leHBvcnQtY29w eS1idWZmZXIpKSkKICAgICAgICAgKHVud2luZC1wcm90ZWN0IChsZXQgKChvcmctY3VycmVudC1l eHBvcnQtZmlsZSByZWZlcmVuY2UpKQogICAgICAgICAgICAgICAgICAgICAgICAgICA7IGJlZ2lu bmluZyBvZiAob3JnLWJhYmVsLWV4cC1wcm9jZXNzLWJ1ZmZlcikKICAgICAgICAgICAgICAgICAg ICAgICAgICAgKG9yZy1iYWJlbC1leHAtbm9uLWJsb2NrLWVsZW1lbnRzIChwb2ludC1taW4pIChw b2ludC1tYXgpKQogICAgICAgICAgICAgICAgICAgICAgICAgICA7IGVuZCBvZiAob3JnLWJhYmVs LWV4cC1wcm9jZXNzLWJ1ZmZlcikKICAgICAgICAgICAgICAgICAgICAgICAgICAgKQogICAgICAg ICAgIChraWxsLWJ1ZmZlciByZWZlcmVuY2UpKSkKICAgIytFTkRfU1JDCgoqIENvZGUgdG8gZXZh bHVhdGUKRXZhbHVhdGUgd2l0aDogKG9yZy1iYWJlbC1sb2FkLWZpbGUgYnVmZmVyLWZpbGUtbmFt ZSkKKiogcmVxdWlyZWQKIytCRUdJTl9TUkMgZW1hY3MtbGlzcCAKKGV2YWwtd2hlbi1jb21waWxl CiAgICAocmVxdWlyZSAnY2wpCiAgICAocmVxdWlyZSAnb3JnLWlkKSkKIytFTkRfU1JDCioqIG5n L2RlY29k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K0JFR0lOX1NSQyBlbWFjcy1saXNwIAooZGVmdW4g bmcvb3JnLWdldC1lbnRyeS10aXRsZSAoJm9wdGlvbmFsIHBvbSkKICAiICogV09SSyBhYSA6Yjog LS0tPiBhYSIKICAob3JnLXdpdGgtcG9pbnQtYXQgcG9tCiAgICAob3JnLW5vLXByb3BlcnRpZXMg KG9yZy1nZXQtaGVhZGluZyAnbm90YWdzICdub3RvZG8pKSkpCiMrRU5EX1NSQwoqKiBuZy9vcmct dGMKIytCRUdJTl9TUkMgZW1hY3MtbGlzcCAKICAoZGVmdW4gbmcvb3JnLXRjIChzKQogICAgKGxl dCogKChhdC1oZWFkaW5nLXAgKG9yZy1hdC1oZWFkaW5nLXApKQogICAgICAgICAgIDsgYXJlIHdl IGNhbGxlZCBieSB0aGUgZXhwb3J0ZXIsIG9yIGp1c3QgQmFiZWwgPwogICAgICAgICAgIChleHBv cnRpbmctcCAoYnVmZmVycCBvcmctY3VycmVudC1leHBvcnQtZmlsZSkpCiAgICAgICAgICAgKGRl YyAobmcvZGVjb2RlLWxpbmsgcykpCiAgICAgICAgICAgKGxpbmsgKGZpcnN0IGRlYykpCiAgICAg ICAgICAgKG5ldy10aXRsZSAocmVzdCBkZWMpKQogICAgICAgICAgIChpZCAob3IgKG5nL2dldC1z eW1saW5rLWlkIHMpIGxpbmspKQogICAgICAgICAgIChjdXJyLWx2IChvciAob3JnLWN1cnJlbnQt bGV2ZWwpIDApKSkKICAgICAgKHVubGVzcyBpZAogICAgICAgIChlcnJvciAoZm9ybWF0ICJObyBp ZCBmb3VuZDogJXMiIHMpKSkKICAgICAgOyhuZy9kZWxldGUtY3VycmVudC1saW5lKQogICAgICAo c2F2ZS1leGN1cnNpb24KICAgICAgICAoc2F2ZS13aW5kb3ctZXhjdXJzaW9uCiAgICAgICAgICAo b3JnLWlkLW9wZW4gaWQpCiAgICAgICAgICAob3JnLWNvcHktc3VidHJlZSkpKQogICAgICAod2l0 aC10ZW1wLWJ1ZmZlcgogICAgICAgIChvcmctbW9kZSkKICAgICAgICAob3JnLXBhc3RlLXN1YnRy ZWUgY3Vyci1sdiBuaWwgbmlsKQogICAgICAgIChvcmctZGVsZXRlLXByb3BlcnR5ICJJRCIpIDsg cHJldmVudHMgSUQgZHVwbGljYXRpb24gaWYgYW4gZW50cnkgZ2V0cyBwYXN0ZWQgc2V2ZXJhbCB0 aW1lcwogICAgICAgIChvcmctYmFjay10by1oZWFkaW5nKQogICAgICAgIChpZiBhdC1oZWFkaW5n LXAKICAgICAgICAgIChwcm9nbgogICAgICAgICAgICA7IFJlbmFtZSB0aGUgaGVhZGluZwogICAg ICAgICAgICAocmVwbGFjZS1zdHJpbmcgKG5nL29yZy1nZXQtZW50cnktdGl0bGUpIG5ldy10aXRs ZSBuaWwgKHBvaW50KSAocG9pbnQtYXQtZW9sKSkKICAgICAgICAgICAgKHdoZW4gZXhwb3J0aW5n LXAKICAgICAgICAgICAgICAob3JnLWJhY2stdG8taGVhZGluZykKICAgICAgICAgICAgICAoc2F2 ZS1leGN1cnNpb24gKHJlcGxhY2UtcmVnZXhwICJcXCorICIgIiIgbmlsIChwb2ludCkgKHBvaW50 LWF0LWVvbCkpKSkpCiAgICAgICAgICA7IGJvZHkgb25seQogICAgICAgICAgKHByb2duCiAgICAg ICAgICAgIChuZy9kZWxldGUtY3VycmVudC1saW5lKSkpCiAgICAgICAgKGJ1ZmZlci1zdHJpbmcp KSkpCiMrRU5EX1NSQwoqIFNvdXJjZSBibG9ja3MKKiogU291cmNlIGJsb2MgMQo6UFJPUEVSVElF UzoKOklEOiAgICAgICA3MDAyZWY1NS02ZDU4LTQ2NWMtYWQ4OS1iOTM5NGJmNmYwODkKOkRVTU1Z X1BST1A6IGR1bW15X3ZhbHVlCjpFTkQ6CkNvbnRlbnRzIG9mIHNvdXJjZSBibG9jIDEKKiogU291 cmNlIGJsb2MgMgo6UFJPUEVSVElFUzoKOklEOiAgICAgICBhZDZhY2Q3MC1iOTdlLTQ0NzktODM4 OC03YTU0NzN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