Re: alternate spanner-id-aware spanner does not work in 2.39.48

2016-10-16 Thread Rutger Hofman

Yes, this helps! Thanks a lot!

Rutger

On 10/16/2016 08:15 PM, David Kastrup wrote:

Rutger Hofman  writes:

Hm, I suspect


((or
  (and
   (string? sp-id)
   (string? es-id)
   (string=? sp-id es-id))
  ;; deal with \startTextSpan, \stopTextSpan
  (and
   (null? sp-id)
   (null? es-id)))


That would be more succinctly be expressed as

  ((equal? sp-id es-id)

In which case it should work equally well in the old and the new
LilyPond versions.  Assuming I counted the parens right.




___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: alternate spanner-id-aware spanner does not work in 2.39.48

2016-10-16 Thread David Kastrup
Rutger Hofman  writes:

Hm, I suspect

> ((or
>   (and
>(string? sp-id)
>(string? es-id)
>(string=? sp-id es-id))
>   ;; deal with \startTextSpan, \stopTextSpan
>   (and
>(null? sp-id)
>(null? es-id)))

That would be more succinctly be expressed as

  ((equal? sp-id es-id)

In which case it should work equally well in the old and the new
LilyPond versions.  Assuming I counted the parens right.

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: alternate spanner-id-aware spanner does not work in 2.39.48

2016-10-16 Thread Rutger Hofman

Finish my sentence at the end of the paragraph:

... No spanners are drawn at all in this example.

On 10/16/2016 07:53 PM, Rutger Hofman wrote:

Hello list,

to my grief I noticed that David Nalesnik's id-aware spanner
implementation in scheme no longer works in 2.39.48. It gives me errors
like "warning: No spanner to end!!" and "warning: incomplete spanner
removed!" if there are overlapping spanners. No

For reference, I again attach David N's (most recent) textspanner
implementation. The \score block is a minimal example.

Note: this worked fine with 2.19.39, and fails with 2.19.48. I didn't
look at intermediate versions.

Rutger




___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


alternate spanner-id-aware spanner does not work in 2.39.48

2016-10-16 Thread Rutger Hofman

Hello list,

to my grief I noticed that David Nalesnik's id-aware spanner 
implementation in scheme no longer works in 2.39.48. It gives me errors 
like "warning: No spanner to end!!" and "warning: incomplete spanner 
removed!" if there are overlapping spanners. No


For reference, I again attach David N's (most recent) textspanner 
implementation. The \score block is a minimal example.


Note: this worked fine with 2.19.39, and fails with 2.19.48. I didn't 
look at intermediate versions.


Rutger

\version "2.19"

%% Incorporating some code from the rewrite in Scheme of
%% Text_spanner_engraver in input/regression/scheme-text-spanner.ly

#(define (add-bound-item spanner item)
   (if (null? (ly:spanner-bound spanner LEFT))
   (ly:spanner-set-bound! spanner LEFT item)
   (ly:spanner-set-bound! spanner RIGHT item)))

#(define (axis-offset-symbol axis)
   (if (eq? axis X) 'X-offset 'Y-offset))

#(define (set-axis! grob axis)
   (if (not (number? (ly:grob-property grob 'side-axis)))
   (begin
(set! (ly:grob-property grob 'side-axis) axis)
(ly:grob-chain-callback
 grob
 (if (eq? axis X)
 ly:side-position-interface::x-aligned-side
 side-position-interface::y-aligned-side)
 (axis-offset-symbol axis)

#(define (assign-spanner-index spanner orig-ls)
   "Determine the position of a new spanner in an ordered sequence
of spanners.  The goal is for the sequence to begin with zero and
contain no gaps.  Return the index representing the spanner's position."
   (if (null? orig-ls)
   0
   (let loop ((ls orig-ls) (insert? #t) (result 0))
 (cond
  ((null? ls) result)
  ;; position at head of list
  ((and insert? (> (caar orig-ls) 0))
   (loop ls #f 0))
  ;; no gaps, put at end of list
  ((and insert? (null? (cdr ls)))
   (loop (cdr ls) #f (1+ (caar ls
  ;; fill lowest position of gap
  ((and insert?
(> (caadr ls) (1+ (caar ls
   (loop (cdr ls) #f (1+ (caar ls
  (else (loop (cdr ls) insert? result))

alternateTextSpannerEngraver =
#(lambda (context)
   (let (;; a list of pairs comprising a spanner index
  ;;  (not spanner-id) and a spanner which has been begun
  (spanners '())
  (finished '()) ; list of spanners in completion stage
  (start-events '()) ; list of START events
  (stop-events '())) ; list of STOP events
 (make-engraver
  ;; \startTextSpan, \stopTextSpan, and the like create events
  ;; which we collect here.
  (listeners
   ((text-span-event engraver event)
(if (= START (ly:event-property event 'span-direction))
(set! start-events (cons event start-events))
(set! stop-events (cons event stop-events)
  ;; Populate 'note-columns property of spanners.  Bounds are
  ;; set to note columns, and each spanner keeps a record of
  ;; the note columns it traverses.
  (acknowledgers
   ((note-column-interface engraver grob source-engraver)
(for-each (lambda (s)
(ly:pointer-group-interface::add-grob
 (cdr s) 'note-columns grob)
(if (null? (ly:spanner-bound (cdr s) LEFT))
(add-bound-item (cdr s) grob)))
  spanners)
;; finished only contains spanners, no indices
(for-each (lambda (f)
(ly:pointer-group-interface::add-grob
 f 'note-columns grob)
(if (null? (ly:spanner-bound f RIGHT))
(add-bound-item f grob)))
  finished)))

  ((process-music trans)
   ;; Move begun spanners from 'span' to 'finished'.  We do this
   ;; on the basis of 'spanner-id.  If we find a match--either
   ;; the strings are the same, or both are unset--a transfer
   ;; can be made.  Return a warning if we find no match: spanner
   ;; hasn't been properly begun.
   (for-each
(lambda (es)
  (let ((es-id (ly:event-property es 'spanner-id)))
(let loop ((sp spanners))
  (if (null? sp)
  (ly:warning "No spanner to end!!")
  (let ((sp-id (ly:event-property
(event-cause (cdar sp)) 'spanner-id)))
(cond
 ((or
   (and
(string? sp-id)
(string? es-id)
(string=? sp-id es-id))
   ;; deal with \startTextSpan, \stopTextSpan
   (and
(null? sp-id)
(null? es-id)))
  (set! finished (cons (cdar sp) finished))
  (set! spanners (remove (lambda (s) (eq? s (car sp))) spanners)))
 (else (loop (cdr sp)
stop-events)

   ;; The