Updating all Fold Executables inside a TeXmacs document

Is there a way to update all Fold Executables inside a TeXmacs document?

I would like to use TeXmacs for generating a dynamic report on a dataset including for example the mean of a variable.
There aren’t many tools which support this kind of workflow and I recently discovered Folds as a very interesting feature of TeXmacs.
The dataset is stored in a external text file. In case a new measurement is added to this file, a possibilty to manually trigger the update (i.e. re-render) the Folds would be very helpful.

This is the beginning of an answer.

Define a function which tests for Scheme executable folds that are in “output” state

(tm-define (exec-scheme-output? t) (and (tree-is? t 'script-output) (equal? (tree->stree (tree-ref tt 0))  "scheme")))

Execute a search applying this function as a search filter and assign the output to the list e-trees

(define e-trees (tree-search (buffer-tree) exec-scheme-output?))

Apply to all elements of the list the function alternate-toggle twice

(for-each (lambda (t) (begin (alternate-toggle t) (alternate-toggle t))) e-trees)

May be there is a better way than applying alternate-toggle twice, but I did not yet find it out. Please let me know if this code helps; you have to combine the parts of the code and assign the resulting code to a keyboard shortcut.

This thread may also be helpful: Reproducible Research "Plugin"

Thanks, for your hints.
In the thread you referred to it is mentioned that it might not be possible to typeset with Folds. I’m wondering what is actually meant by that.

I re-read it. I think I meant the following: say that the output of the fold is a string which represents a sentence, with words separated by blanks. Does TeXmacs treat it like an unbreakable box, or does TeXmacs treats it like all of its other strings of characters? I never tried :slight_smile:

I tried. TeXmacs typesets a string which is output by a Scheme Executable folds; it does not allow, though, to place the executable fold inline, it has to be in a paragraph of its own

Thanks for trying it out and your answer.

Putting the output of executable folds inline would be a helpful feature for report generation (i.e. what is nowadays also called reproducible research).

I did not re-read the thread Reproducible Research “Plugin”. What do you think is missing in the ways to generate a report proposed there?

The use case discussed in http://forum.texmacs.cn/t/reproducible-research-plugin/401 is a good one: a statistical test is performed on a dataset and the result (p-value) should be inserted inline (i.e. within a written paragraph) inside the document.
This is currently not trivial to do in TeXmacs, particularly if you think about special cases like scientific (exponential) notation if a value is very small.

I think the format function from the ice-9 module may help: https://www.gnu.org/software/guile/manual/html_node/Formatted-Output.html

I tested one of the examples in TeXmacs 2.1.4 and it works.

I would compose the format function with one of the functions proposed in Reproducible Research "Plugin". If you are interested and need some help I can try and write a small example.