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

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.

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

Reply via email to