With the help of @jeroen above, I have fixed the code, adding to the macros an argument which I do not use (I do not know how to rewrite the macros and Scheme code to make the folding-unfolding work with one argument only).
I am not able to fit both the macros and the Scheme code in the style file, so I had to call the Scheme code in the style file with the use-module
macro
I placed the following in a style file (in the styles
directory of my personal initialization directory) which I called fold-unfold.ts
<use-package|generic>
<use-module|(styles fold-unfold)>
<assign|u-sol|<macro|dummy|body|<unfolded|<with|font-series|bold|solution>|<arg|body>>>>
<assign|f-sol|<macro|dummy|body|<folded|<with|font-series|bold|solution>|<arg|body>>>>
then in my personal initialization directory I used a directory progs/styles
which I had already placed there for other Scheme files and added in there a file called fold-unfold.scm
with the following content
(texmacs-module (styles fold-unfold))
(define-fold f-sol u-sol)
By setting as style file in a document fold-unfold
(since the style file is in the styles
directory, TeXmacs lists it in the menu) I have the macros available which fold and unfold.
Then you can adapt to your wishes.
I think that with styles this is the maximum “self-containment” that you can achieve.