From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Ecay Subject: Re: problems with export and :cache Date: Thu, 29 Oct 2015 13:34:50 +0000 Message-ID: <87vb9pyf0l.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42460) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrnM4-0006H3-Im for emacs-orgmode@gnu.org; Thu, 29 Oct 2015 09:35:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrnM1-0002Uy-AI for emacs-orgmode@gnu.org; Thu, 29 Oct 2015 09:35:00 -0400 Received: from mail-wi0-x234.google.com ([2a00:1450:400c:c05::234]:37171) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrnM0-0002Ul-R9 for emacs-orgmode@gnu.org; Thu, 29 Oct 2015 09:34:57 -0400 Received: by wicfv8 with SMTP id fv8so43169038wic.0 for ; Thu, 29 Oct 2015 06:34:56 -0700 (PDT) In-Reply-To: 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: Andreas Leha , emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Andreas, 2015ko urriak 28an, Andreas Leha-ek idatzi zuen: >=20 > Hi all, >=20 > Andreas Leha writes: >> Hi all, >>=20 >> babel's :cache seems to be ignored during export. At least on #+call >> lines. >>=20 >> In the example below the caching works fine for interactive evaluation, >> i.e. C-c C-c on the #+call line returns immediately. >>=20 >> If I export the subtree with the #+call line, however, the code block >> gets executed and the export is slow. Export works by making a copy of the org buffer, modifying it in some ways while executing babel code, then exporting the modified buffer copy. The modifications can under some circumstances change the relevant features for the cache, leading to spurious re-evaluation. I tried to write a patch that would do the buffer modifications in such a way that they would not affect the cache. But I was never happy with the patch, and also could not find a nice simple test case for the re-evaluation bug. So this work never went anywhere. (It was also 2 years ago, so things could have changed quite a bit.) The simple patch attached to this message fixes a bug that my testing indicated was responsible for erroneous re-evaluations at least some of the time. I personally regard the babel cache as dangerous and unpredictable in its present form. You=E2=80=99re much better off using language-specific caching/memoization features and/or a disciplined regime of manual reevaluation. >>=20 >> I'd expect no evaluation even during export. >>=20 >> Is this a bug or am I missing something? >>=20 >> Regards, >> Andreas >>=20 >> PS: The example: >>=20 >> * Test Cached Export >> ** A long running code block. >> #+name: foo >> #+begin_src emacs-lisp :var bar=3D"baz" >> (sit-for 15) >> (message "bar=3D%S" bar) >> #+end_src >>=20 >> #+RESULTS: foo >> : bar=3D"baz" >>=20 >> ** Calling >>=20 >> Exporting this subtree will demonstrate my problem. I expect the call >> line below to not execute anything. This works for interactive >> execution (C-c C-c). But if I export this subtree only, the code is >> executed. >>=20 >> This returns immediately thanks to the cached result. >> #+call: foo("qux") :cache yes >>=20 >> #+results[f2b650eb5296f72a1f7237c2a65b7fb3443acf5f]: >> : bar=3D"qux" >=20 >=20 > I should have added that adding :eval no-export to the #+call line does > not help either. There are two places you could add the :eval option. See (info "(org) Evaluating code blocks") . You may have to experiment with putting it in one or both places in order to get the desired result. (If none of the possible combinations works, then it is a bug IMO.) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-babel-fix-header-arg-duplication.patch >From d7355798edc643bbbca7ab1ead2a2e11f37aa64c Mon Sep 17 00:00:00 2001 From: Aaron Ecay Date: Thu, 29 Oct 2015 13:31:28 +0000 Subject: [PATCH] babel: fix header arg duplication * lisp/ob-core.el (org-babel-process-params): Make idempotent. * testing/lisp/test-ob.el (ob/process-params-no-duplicates): New test. --- lisp/ob-core.el | 8 +++++++- testing/lisp/test-ob.el | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 61753ce..fd6d785 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -1597,7 +1597,13 @@ shown below. (cons :result-type (cond ((member "output" result-params) 'output) ((member "value" result-params) 'value) (t 'value)))) - (org-babel-get-header params :var 'other)))) + (loop for item in params + unless (memq (car item) '(:colname-names + :rowname-names + :result-params + :result-type + :var)) + collect item)))) ;; row and column names (defun org-babel-del-hlines (table) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index 508a3ed..c2feb39 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -1477,6 +1477,18 @@ echo \"$data\" (should (equal "foo\\\"bar" (org-babel-script-escape "\"foo\\\\\\\"bar\"")))) +(ert-deftest ob/process-params-no-duplicates () + (should (equal (org-babel-process-params '((:colname-names . 1) + (:rowname-names . 1) + (:result-params . 1) + (:result-type . 1) + (:var . "\"foo\""))) + '((:var) + (:colname-names . 1) + (:rowname-names . 1) + (:result-params . 1) + (:result-type . value))))) + (provide 'test-ob) ;;; test-ob ends here -- 2.6.2 --=-=-= Content-Type: text/plain -- Aaron Ecay --=-=-=--