Can we get a directive to repeat a section? #ChordPro #needinfo

Scott Selberg

On my wishlist for the chordpro format is a tag to repeat a previous section.  Say for example I have:

{start_of_verse: Verse 1}
Happy [C]Birthyday to [G7]You
Happy [C]Birthyday to [G7]You
Happy [C]Birthyday dear [F]Chordpro
Happy [C]Birthyday [G7]to [C]You

I would love to be able to insert the following later in the song

{repeat: Verse 1}

and have it insert all of the lines from the verse.  Now one of the things I
really like about the current reference implementation is how it seperates
the song information from the stylistic rendering.  So it would be nice to
have a style rendering for 'repeats' to print out all of the lines in the repeated
section, print it like a comment line, or not anything.

This would help to follow the principal of DRY (do not repeat yourself) coding. 
So if you have a song which repeats a chorus or a verse you could insert
a repeat directive in the second and further repeats.

A lot of chordpro files have ways of describing a road map.  This would be
nice in that you could insert the repeat directive to make it so you just 
read top to bottom for the road map.  People who know the section or 
like to just look back could use the setting to print the repeat like a comment;
People who want everything written out could use the 'insert as full'.  And 
people who want to keep everything realy compact could tell chordpro to
not print the repeats.

In terms of implmentation, this should be pretty straightforward to scan
the chordpro text for sections, then look for repeat directives that match
a detected section and then substitute the text.  If there is no match, just
replace {repeat:...} with {c:...} to make it a comment.  Then process the
document as normal.

What are people's thoughts about this?

Johan Vromans

I get the feeling you are actually looking for some kind of folding mode, where for each section (verse, chorus, ...) you can control whether it is shown in full, or only a reference.

Or are you really trying to save a pair of cut/paste operations?

Jan Stühler

I hope that this email will be added to the correct thread. I don't have the original email thread because I joined the group after the OP.

I'd also like to vote for the possibility to repeat sections. Sometimes, a prechorus, an ad-lib, a verse in the song repeats one or multiple times. Not necessarily as often as the chorus, and also not everytime directly before or after the chorus.

For me, it's not so much the laziness of copying and pasting, but rather the thus invoked errors. Example: copied a prechorus three times, then see a typo. Need to correct the typo three times.
Or, want another text passage in my self created song. Need to correct that three times.

The {start_of_chorus: Chorus} section can easily be repeated by using {Chorus}. Unfortunately, a (second) {start_of_chorus: Prechorus} or a {start_of_verse: Verse 1} cannot. For me, a simple {Prechorus} or {Verse 1} without a {repeat: x} would be perfectly sufficient.