Dear all,

I know this thread is ancient, but I am only now in the process of upgrading from Lilypond 2.12.2 to 2.18, and I used the attached function alignGrob quite heavily. Unfortunately, it does not work in 2.18 any more, and I do not know enough about the Lilypond internals (and about scheme) to fix it myself. Here is what happens if I try to compile the attached file from David:

~/test> convert-ly alignGrob-update.ly > align.ly
convert-ly (GNU LilyPond) 2.18.0

convert-ly: Processing `alignGrob-update.ly'...
Applying conversion: 2.15.7, 2.15.9, 2.15.10, 2.15.16, 2.15.17, 2.15.18, 2.15.19, 2.15.20, 2.15.25, 2.15.32, 2.15.39, 2.15.40, 2.15.42, 2.15.43, 2.16.0, 2.17.0, 2.17.4, 2.17.5, 2.17.6, 2.17.11, 2.17.14, 2.17.15, 2.17.18, 2.17.19, 2.17.20, 2.17.25, 2.17.27, 2.17.29, 2.17.97


~/test> lilypond align.ly
GNU LilyPond 2.18.0
Processing `align.ly'
Parsing...
align.ly:51:3: error: bad grob property path (TextScript)

  \alignGrob #"TextScript" #'KeySignature #0 #6
align.ly:7:54: warning: Ignoring non-music expression
    \overrideProperty  $grob-to-align #'extra-offset
                                                     #(lambda (grob)
align.ly:51:46: error: error in #{ ... #}
  \alignGrob #"TextScript" #'KeySignature #0
                                             #6
align.ly:53:3: error: bad grob property path (TextScript)

  \alignGrob #"TextScript" #'Clef #1 #5.5
align.ly:7:54: warning: Ignoring non-music expression
    \overrideProperty  $grob-to-align #'extra-offset
                                                     #(lambda (grob)
align.ly:53:38: error: error in #{ ... #}
  \alignGrob #"TextScript" #'Clef #1
                                     #5.5
align.ly:58:3: error: bad grob property path (TextScript)

  \alignGrob #"TextScript" #'BarLine #0 #-5.5
align.ly:7:54: warning: Ignoring non-music expression
    \overrideProperty  $grob-to-align #'extra-offset
                                                     #(lambda (grob)
align.ly:58:41: error: error in #{ ... #}
  \alignGrob #"TextScript" #'BarLine #0
                                        #-5.5
align.ly:60:3: error: bad grob property path (TextScript)

  \alignGrob #"TextScript" #'Hairpin #1 #1
align.ly:7:54: warning: Ignoring non-music expression
    \overrideProperty  $grob-to-align #'extra-offset
                                                     #(lambda (grob)
align.ly:60:41: error: error in #{ ... #}
  \alignGrob #"TextScript" #'Hairpin #1
                                        #1
align.ly:62:3: error: bad grob property path (TextScript)

  \alignGrob #"TextScript" #'Slur #0 #0
align.ly:7:54: warning: Ignoring non-music expression
    \overrideProperty  $grob-to-align #'extra-offset
                                                     #(lambda (grob)
align.ly:62:38: error: error in #{ ... #}
  \alignGrob #"TextScript" #'Slur #0
                                     #0
align.ly:64:3: error: bad grob property path (TextScript)

  \alignGrob #"TextScript" #'StaffSymbol #0 #0
align.ly:7:54: warning: Ignoring non-music expression
    \overrideProperty  $grob-to-align #'extra-offset
                                                     #(lambda (grob)
align.ly:64:45: error: error in #{ ... #}
  \alignGrob #"TextScript" #'StaffSymbol #0
                                            #0
align.ly:69:3: error: bad grob property path (TextScript)

  \alignGrob #"TextScript" #'TimeSignature #-1 #-5
align.ly:7:54: warning: Ignoring non-music expression
    \overrideProperty  $grob-to-align #'extra-offset
                                                     #(lambda (grob)
align.ly:69:48: error: error in #{ ... #}
  \alignGrob #"TextScript" #'TimeSignature #-1
                                               #-5
align.ly:71:3: error: bad grob property path (TextScript)

  \alignGrob #"TextScript" #'TimeSignature #1 #-5
align.ly:7:54: warning: Ignoring non-music expression
    \overrideProperty  $grob-to-align #'extra-offset
                                                     #(lambda (grob)
align.ly:71:47: error: error in #{ ... #}
  \alignGrob #"TextScript" #'TimeSignature #1
                                              #-5
align.ly:75:3: error: bad grob property path (TextScript)

  \alignGrob #"TextScript" #'Stem #0 #-5.5
align.ly:7:54: warning: Ignoring non-music expression
    \overrideProperty  $grob-to-align #'extra-offset
                                                     #(lambda (grob)
align.ly:75:38: error: error in #{ ... #}
  \alignGrob #"TextScript" #'Stem #0
                                     #-5.5
align.ly:77:3: error: bad grob property path (TextScript)

  \alignGrob #"TextScript" #'Accidental #0 #0
align.ly:7:54: warning: Ignoring non-music expression
    \overrideProperty  $grob-to-align #'extra-offset
                                                     #(lambda (grob)
align.ly:77:44: error: error in #{ ... #}
  \alignGrob #"TextScript" #'Accidental #0
                                           #0
align.ly:82:3: error: bad grob property path (Stem)

  \alignGrob #"Stem" #'NoteHead #0 #0
align.ly:7:54: warning: Ignoring non-music expression
    \overrideProperty  $grob-to-align #'extra-offset
                                                     #(lambda (grob)
align.ly:82:36: error: error in #{ ... #}
  \alignGrob #"Stem" #'NoteHead #0
                                   #0
align.ly:84:3: error: bad grob property path (Stem)

  \alignGrob #"Stem" #'NoteHead #0 #0
align.ly:7:54: warning: Ignoring non-music expression
    \overrideProperty  $grob-to-align #'extra-offset
                                                     #(lambda (grob)
align.ly:84:36: error: error in #{ ... #}
  \alignGrob #"Stem" #'NoteHead #0
                                   #0
align.ly:85:3: error: bad grob property path (Script)

  \alignGrob #"Script" #'BarLine #0 #0.5
align.ly:7:54: warning: Ignoring non-music expression
    \overrideProperty  $grob-to-align #'extra-offset
                                                     #(lambda (grob)
align.ly:85:37: error: error in #{ ... #}
  \alignGrob #"Script" #'BarLine #0
                                    #0.5
align.ly:86:3: error: bad grob property path (TextScript)

  \alignGrob #"TextScript" #'StaffSymbol #1 #0
align.ly:7:54: warning: Ignoring non-music expression
    \overrideProperty  $grob-to-align #'extra-offset
                                                     #(lambda (grob)
align.ly:86:45: error: error in #{ ... #}
  \alignGrob #"TextScript" #'StaffSymbol #1
                                            #0
Interpreting music...
Preprocessing graphical objects...
Finding the ideal number of pages...
Fitting music on 1 page...
Drawing systems...
Layout output to `align.ps'...
Converting to `./align.pdf'...
fatal error: failed files: "align.ly"


Any ideas what is going wrong?

Thanks in advance!

Matthias


-------- Original Message --------
Subject: Re: Ragged right for contents but not staff?
Date: Mon, 11 Jul 2011 15:58:43 -0500
From: David Nalesnik <[email protected]>
To: Wilbert Berendsen <[email protected]>
CC: [email protected]

On 7/11/11, Wilbert Berendsen <[email protected]> wrote:

And to place an ending bar line on the end of the last line I use the
alignGrob trick posted to this list sometime ago:

http://old.nabble.com/Re%3A-left-aligning-grobs-to-other-grobs-p31138286.html


Hi, Wilbert --

Since you found a use for that function, I thought I'd post a newer
version with some improvements (including suggestions from Gilles
Thibault).

Best,
David



\version "2.14.1"

alignGrob =
#(define-music-function (parser location grob-to-align reference-grob dir corr)
                        (string? symbol? number? number?)
 #{
    \overrideProperty  $grob-to-align #'extra-offset #(lambda (grob)
      (let* ((sys (ly:grob-system grob))
             (array (ly:grob-object sys 'all-elements))
             (default-coord (ly:grob-relative-coordinate grob sys X))
             (grob-name (lambda (x) (assq-ref (ly:grob-property x 'meta) 'name)))
             (lst (filter
                    (lambda (x) (eq? $reference-grob (grob-name x)))
                    (ly:grob-array->list array))))

      ;; find the grob with the X-coordinate closest to object to be aligned
        (let ((ref (car lst)))
           (define closest (lambda (x)
             (if (< (abs (- default-coord
                            (ly:grob-relative-coordinate (car x) sys X)))
                    (abs (- default-coord
                            (ly:grob-relative-coordinate ref sys X))))
                 (set! ref (car x)))
             (if (not (null? (cdr x)))
                 (closest (cdr x)))))

          (closest lst)

     ;; return extra-offset based on choice of alignment
            (cons
              (cond ((< $dir 0) (- (car (ly:grob-extent ref sys X))
                                   (car (ly:grob-extent grob sys X))))
                    ((= $dir 0) (- (interval-center (ly:grob-extent ref sys X))
                                   (interval-center (ly:grob-extent grob sys X))))
                    ((> $dir 0) (- (cdr (ly:grob-extent ref sys X))
                                   (cdr (ly:grob-extent grob sys X)))))
              $corr))))
  #}
)

ln = \markup \with-color #red \draw-line #'(0 . 6)
uparrow = \markup \combine \arrow-head #Y #UP ##f \draw-line #'(0 . -2)
downarrow = \markup \combine \arrow-head #Y #DOWN ##f \draw-line #'(0 . 2)

\relative c' {

  %% bar 1
  \time 3/4
  \key d \major
  d
  \alignGrob #"TextScript" #'KeySignature #0 #6
  e-\ln
  \alignGrob #"TextScript" #'Clef #1 #5.5
  fis-\ln

  %% bar 2
  \time 5/4
  \alignGrob #"TextScript" #'BarLine #0 #-5.5
  e^\ln
  \alignGrob #"TextScript" #'Hairpin #1 #1
  d(_\ln
  \alignGrob #"TextScript" #'Slur #0 #0
  e_\uparrow
  \alignGrob #"TextScript" #'StaffSymbol #0 #0
  fis^\markup \center-column { "mid-staff" \downarrow  } d)\<

  %% bar 3
  \time 3/4
  \alignGrob #"TextScript" #'TimeSignature #-1 #-5
  e^\ln
  \alignGrob #"TextScript" #'TimeSignature #1 #-5
  fis^\ln d

  %% bar 5
  \alignGrob #"TextScript" #'Stem #0 #-5.5
  e\!^\ln fis
  \alignGrob #"TextScript" #'Accidental #0 #0
  d!_\uparrow

  %% bar 6
  \time 2/4
  \alignGrob #"Stem" #'NoteHead #0 #0
   fis
  \alignGrob #"Stem" #'NoteHead #0 #0
  \alignGrob #"Script" #'BarLine #0 #0.5
  \alignGrob #"TextScript" #'StaffSymbol #1 #0
  d\fermata _"end"
  \bar "||"
}

_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to