Hi,

I have a custom engraver 
(https://github.com/nwhetsell/lilypond-instrument-name-measuring-engraver) that 
helps align instrument names like what’s shown on p. 509 of Elaine Gould’s 
Behind Bars. In a nutshell, this engraver works by measuring the x extent of 
system start text stencils, remembering the largest widths, and then reporting 
those widths (using ly:message) so they can be used as indents in a paper block.

It would be better, though, if the engraver set paper indents directly using (I 
believe) ly:output-def-set-variable! 
<https://lilypond.org/doc/v2.25/Documentation/internals/scheme-functions#index-ly_003aoutput_002ddef_002dset_002dvariable_0021>.
 Unfortunately, this doesn’t seem to work. Running

(ly:output-def-set-variable! paper 'indent indent)

does not change the indent (paper is `(ly:parser-lookup '$defaultpaper)`).

Is it possible to set paper indents in an engraver using Scheme? Any help would 
be greatly appreciated! A small test program follows.

Many thanks,
Nate

\version "2.25.11"

\include 
"lilypond-instrument-name-measuring-engraver/instrument-name-measuring-engraver.ily"

\score {
  <<
    \new Staff \with {
      instrumentName = "Name"
      shortInstrumentName = "Nm."
    } {
      s1 \pageBreak s1
    }

    \new Staff \with {
      instrumentName = "Very very very long name"
      shortInstrumentName = "V.v.v.lng.nm."
    } {
      s1*2
    }
  >>

  \layout {
    \context {
      \Score
      \consists #Instrument_name_measuring_engraver
    }
  }
}

\paper {
  left-margin = 0.75\in
  top-margin = 0.5\in
  right-margin = 0.75\in
  bottom-margin = 0.5\in

  % Uncomment these lines to show the effect of the indents.
  % indent = 138.24456692913384\pt
  % short-indent = 73.03085039370077\pt
}

Reply via email to