And @David Kastrup : thank you very much for telling me how to achieve the same name for environment and command !
2017-11-19 22:05 GMT+01:00 Abbé Jacques Peron <[email protected]> : > I found the problem : it came from @currenv, that is in fact @currenvir. > After last modifications > <https://github.com/jperon/lyluatex/commit/53ed227b4857b19d95598f1d25100e508c685c3c>, > I think lyluatex should work as a drop-in replacement for lilypond-book, > while keeping backward compatibility for those who already used lyluatex. > > Please feel free to test and report bugs > <https://github.com/jperon/lyluatex/issues> ! > > > 2017-11-19 20:54 GMT+01:00 Abbé Jacques Peron < > [email protected]>: > >> Just tried that, and it doesn’t work : >> >> \let\lilypond@envcode\lilypond >> \protected\def\lilypond{\def\reserved@a{lilypond}% >> \ifx\reserved@a\@currenv \expandafter\lilypond@envcode >> \else \expandafter \lily \fi} >> >> I think it has something to do with \expandafter, but I don’t know TeX >> enough to be sure… >> >> >> >> 2017-11-19 20:39 GMT+01:00 Abbé Jacques Peron < >> [email protected]>: >> >>> Neither are called lilypond. It's not particularly great, but there are >>>>> examples for the sharing of command and environment. Basically you >>>>> check whether @currenvir is set to LilyPond. As long as you don't >>>>> _nest_ those constructs... >>>>> >>>>> The environment is defined as `ly`, but there is a `lilypond` alias. >>> So `\begin{lilypond}` just works. >>> >>> Basically: >>>>> >>>>> \newenvironment{lilypond} >>>>> {...} >>>>> {...} >>>>> >>>>> \newcommand{\lilypondcommand}{...} >>>>> >>>>> \let\lilypond@envcode\lilypond >>>>> \protected\def\lilypond{\def\reserved@a{lilypond}% >>>>> \ifx\reserved@a\@currenv \expandafter\lilypond@envcode >>>>> \else \expandafter \lilypondcommand \fi} >>>>> >>>>> Ugly, sure. But I think LilyPond upstream would be sympathetic to >>>>> making command and environment named differently in the long run. >>>>> >>>>> >>> I'm going to try it just now. >>> >>> I don’t know enough about (La?)TeX internals to understand the code >>>> above but if you redefined the command \lilypond, would things like the >>>> following still be possible? >>>> >>>> \newenvironment{dly}{ >>>> \center >>>> \ly >>>> \language "deutsch" >>>> >>>> \paper { >>>> ##(define fonts >>>> (set-global-fonts >>>> ##:music "cadence" >>>> ##:brace "cadence" >>>> ##:roman "Vollkorn" >>>> ##:factor (/ staff-height pt 20))) >>>> } >>>> >>>> \layout { >>>> % some other general things >>>> } >>>> >>>> % some includes and function definitions >>>> }{\endly\endcenter} >>> >>> >>> As you are using `\ly`, as soon as I don't modify it, it'll work. >>> >> >> >
_______________________________________________ lilypond-user mailing list [email protected] https://lists.gnu.org/mailman/listinfo/lilypond-user
