I'm wondering if there is a way to use macros or some other built-in Gregorio TeX feature to conditionally "turn on" or "turn off" sections of a gabc file so they do or do not appear.
For example, in some documents a particular chant may occur on several occasions (in my own work, one responsory appears 4 times). Sometimes this is with or without an alleluia for Paschaltide, or with or without a Gloria Patri at ending, or some other seasonal variation. Or maybe an antiphon is doubled and so printed both before and after a long psalm, but you only want to print the EUOUAE in the copy at the beginning and suppress it at the end.
If such a feature existed, one could keep the chant in a single file and maybe turn portions on or off by setting a TeX \if switch to true or false and testing for that within the tex macro within the gabc file to turn on or off printing of a group of syllables. So set \ifalleluia to true if you want the alleluia portion to print for Paschaltide or set \ifgloria to true to get the Gloria Patri to print.
This would be desirable in large works to cut down on possible typos and discrepancies by having a single electronic version of something used in multiple locations.
I tried to do this with the "comment" package, but that is trying to use a blunderbuss. Comment will treat everything between \begin{comment} and \end{comment} as if it were a comment (e.g. line starts with %); but since it is an environment, it quite predictably falls afoul of parenthesis grouping in the Gregorio TeX internals when I try to use it.
My basic example (without even getting to adding any \if switches yet) is below. I've ignorantly tried the macros at every level ([em1], [gm1],[nm1]) or with <v> tags and it's a no go.
Test.tex:
---------------
% !TEX TS-program = lualatex
\documentclass[12pt]{book}
\usepackage[autocompile]{gregoriotex}
\usepackage{comment}
\begin{document}
\gregorioscore{test1}
\end{document}
test1.gabc
--------------------
name:test;
def-m1:\begin{comment};
def-m2:\end{comment};
%%
% Hopefully only prints syllables on the note f without any weird extra spaces.
(c4) Test(f) this(f) now([em1]h) and(h) hope(h) to([em2]f) continue(f) (::)