As detailed above in this thread, my problem was trying to define an environment to apply as a style change to gregorio styles firstsyllableinitial or firstword or anything else, really. Fr. Samuel helpfully provided a link (
https://tex.stackexchange.com/a/249629) referencing a similar problem in which the solution was to define an environment using NewEnviron from the environ package which allows you to create an environment in which a command is applied to the body of the text supplied to the environment.
Unfortunately, I've had no luck getting this to work. I can define the environments and they work in the body of the program, but I get errors complaining of an extra } when I try to use \grechangestyle to apply them to the gregorio environments in question.
This is obviously because I don't know enough about expansion/protection/macro arguments/scope etc. But if someone could show me where I'm off, I'd appreciate it. The goal is to use \MakeUppercase to make the first word upper case. See MWE. I enclose 4 attempts AAA, BBB, CCC, DDD, of which exactly one should be uncommented to run. Only the most naive works, and won't suit my purposes since \MakeUppercase is fussier in ways I understand only a little bit.
The example uses etools robustify to help, but it doesn't seem to work in my case, or I can't figure it out.
I sincerely appreciate any help or pointers.
Rob
MWE
% !TEX TS-program = lualatex
% !TEX encoding = UTF-8
\documentclass{book}
\usepackage[autocompile]{gregoriotex}
\usepackage{environ}
\usepackage{etoolbox}
% Make the body of the environment upper case.
\NewEnviron{fword}{%
\MakeUppercase{\BODY}}
%Make the body of the environment small caps
\NewEnviron{myword}{%
\scshape \BODY}
%%% Choose one of AAA, BBB, CCCC, or DDDDD and comment out the others.
%%% The goal is to have something like AAA with \MakeUppercase work.
%%%
% AAA - what I'm trying to do.
%This does not work
\grechangestyle{firstword}{\begin{fword}}%
[\end{fword}]
%%%%%
%BBB
% Surprisingly this partially executes and is somewhat closer but obviously flawed.
%\grechangestyle{firstword}{\MakeUppercase}
%%%
%CCC
%This does not work so it's not just about \Makeuppercase
%\grechangestyle{firstword}{\begin{myword}}[\end{myword}]
%%%%%%%%%
%DDDD
%This will work even though CCC fails.
%\grechangestyle{firstword}{\scshape}
\begin{document}
\begin{fword}
Hello, World!
\end{fword}
\begin{myword}
Hello, World!
\end{myword}
\gabcsnippet{(c4) De(g)re(g)lín(h>)quat<sp>*</sp>(g) ím(h)pi(g)us(f) vi(g)am(hj~) su(ji!jwkjk)am,(kj) (::)}
\end{document}