The cache feature in org-babel relies on the results of the block
being printed in the buffer, but that only happens if you evaluate a
block directly. However, if you evaluate a block as a dependency of
another, it no longer works. For example if we have these two blocks

#+name: random
#+begin_src emacs-lisp :cache yes :results value :results replace
(number-to-string (random 100))
#+end_src

#+begin_src emacs-lisp :var x=random :results replace :results value
  (+ (string-to-number x) 1)
#+end_src

If you evaluate the first block explicitly once, and then the second
block multiple times, the result of the second block never changes,
because the result of the first block is cached.

But if you evaluate the second block directly without evaluating the
first one explicitly, and do it a few times, you'll get a different
result each time.

Does it make sense to add a configuration variable for printing the
results of blocks evaluated indirectly to fix this? It could have the
following values:
- nil (default): Don't print the results of blocks evaluated
  indirectly, as it's done now
- 'cache: do it only if the block has a cache header argument
- t: Do it always

WDYT? I guess it should be relatively easy to do it with the pieces
that already exist, so if you agree it's a good idea I can try

Reply via email to