lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need multiple \mark entries over the same barline


From: Thomas Morley
Subject: Re: Need multiple \mark entries over the same barline
Date: Wed, 30 Jul 2014 22:24:42 +0200

2014-07-30 14:39 GMT+02:00 David Kastrup <address@hidden>:
> Thomas Morley <address@hidden> writes:
>
>> Hi David,
>>
>> may I ask you to have a look?
>>
>> There's an optional argument failing with a single use-case and I've
>> no clue why.
>> Did I something wrong?
>>
>> (You may want to skip most of the mail and go to the REMARK)
>
> Optional argument declaration syntax conflicts with the use of anonymous
> lambda functions.  Actually, I would expect the main problem to be the
> other way round: a lambda function used as a regular predicate gets
> confused with an actual argument.  But since anonymous functions don't
> work with mandatory arguments, using them for optional arguments is not
> likely a good idea either.
>
> At any rate, the example is far too complex to sensibly "have a look".
> Can you reduce this to something smaller?
>
> --
> David Kastrup

Here a simplified code.
It fails if the markup is entered directly, like \markup "X"
Entering it in scheme-syntax or as a predefined markup works.
Seems to make no difference whether the function uses (lambda (x) ...)
or an predefined predicate.

#(define (combine-markup-default-mark alist text)
   (lambda (grob)
     (let* ((axis (or (assoc-ref alist 'axis) Y)))

      (ly:grob-set-property! grob 'stencil
        (ly:stencil-combine-at-edge
          (ly:grob-property grob 'stencil)
          axis
          1
          (grob-interpret-markup grob text)
          0)))))

#(define (alist? x)
  (and (list? x) (every pair? x)))

%% Using lambda or the predefined alist?-predicate seems to make no difference
addMarkupToRehearsalMark =
#(define-music-function (parser location alist mrkp)
;(((lambda (x) (and (list? x) (every pair? x))) '()) markup?)
((alist? '()) markup?)

#{
        \once \override Score.RehearsalMark #'before-line-breaking =
          #(combine-markup-default-mark alist mrkp)
#})

%%%%%%%%%%%%%%%
% EXAMPLES
%%%%%%%%%%%%%%%

% This works, because the alist-argument is specified.
% Just showing a possible use case
\relative c' {
     \addMarkupToRehearsalMark #'()
       \markup "X"
       \mark \default
    c1
     \addMarkupToRehearsalMark #`((axis . ,X))
       \markup "X"
       \mark \default
    c1
}

% Examples with not specified alist-argument

% This fails for unknown reason!
\relative c' {
%{
  \addMarkupToRehearsalMark
    \markup "X"
    \mark \default
%}
  d1
}

% Entering the markup in scheme works (!)
\relative c' {
     \addMarkupToRehearsalMark
       #(markup "X")
       \mark \default % H
    e1
}

% Predefining the markup works (!)
x-mrkp = \markup "X"

\relative c' {
     \addMarkupToRehearsalMark
       \x-mrkp
       \mark \default % H
    f1
}

Cheers,
  Harm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]