Thanks. There's a lot to look at here, as I'm not (yet?) a Scheme/Guile programmer! But as you hint it doesn't seem to work, though. The bar number check works, but the printed bar numbers are still sequential, which I don't understand.
But it's also essential that the performer is told how many times to repeat each fragment! At the moment I've chickened out and used percent repeats with counts :(
-------------------------
> Without investigating how the bar number engraver (I'm guessing, or
> whatever engraves them), I am unsure how to correct what actually
> gets *engraved* (which is obviously important), but here's a partial solution.
>
> \adjustBarNum applies the repeats and does the calculations, and
> seems to reset each next *currentBarNumber* to what it should be.
> Maybe someone with more knowledge of how bar numbers are engraved
> can have a look and see what is wrong/missing.