Ignacio Casso <[email protected]> writes:

>> Maybe.
>> I am looking into this again, and, while browsing through the code, I
>> found 'org-babel-update-intermediate'. It is even more broad, but should
>> cover your purposes, I think.
>
> Yes, it covers my case, thanks!
>
> We could leave it at this then, but I think we should make it more
> discoverable, it was originally a defcustom, but was later changed to a
> defvar to silence some warning, so now it's hard to find. Maybe while we
> are at it we can add the option to only apply it for cached blocks.

Sounds reasonable. I have no objections.

> Also, while trying to understand how it works, I discovered another bug
> related to it. Where that variable is used in the code, if it's non-nil
> the variable `params` stops being used, but those params are responsible
> of one more thing than overriding the results header argument, they are
> also used for example to pass specific variable values to a block
> reference. See this example for example
>
> #+name: random
> #+begin_src emacs-lisp :results replace :cache yes :var max=100
>   (message "random is called")
>   (random max)
> #+end_src
>
> #+begin_src emacs-lisp :var x=random(max=5) :results replace
>   (message "main is called")
>   x
> #+end_src
>
> If you evaluate the second block several times, you'll see that the
> result changes but it's always between 0 and 4. However, if we set the
> `org-babel-update-intermediate` variable to non-nil and try to evaluate
> again, the cache does indeed work and the result no longer changes, but
> the returned number is most likely greater than 5.

Yup. Also, it is ignored in the babel calls.
And, for a good measure, we may suppress the effects in read-only buffers.

> I will try to write a patch that addresses all the issues I mentioned
> and share it here.

Looking forward.

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to