lilypond-devel
[Top][All Lists]
Advanced

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

Re: Add the command \offset to LilyPond (issue 8647044)


From: david . nalesnik
Subject: Re: Add the command \offset to LilyPond (issue 8647044)
Date: Sun, 20 Oct 2013 20:35:21 +0000

On 2013/10/20 16:15:56, dak wrote:
On 2013/10/20 15:51:57, david.nalesnik wrote:
>
https://codereview.appspot.com/8647044/diff/48001/scm/music-functions.scm
> File scm/music-functions.scm (right):
>
>

https://codereview.appspot.com/8647044/diff/48001/scm/music-functions.scm#newcode2118
> scm/music-functions.scm:2118: (let* ((immutable
(ly:grob-basic-properties
grob))
> I just noticed something unfortunate while attempting to write
documentation
for
> \offset.  Basically, `property' needs to be specified using the
older notation
> -- i.e., with #' prefixed.

I suggest looking at the code in issue 3625.  That "sloppy" approach
let's you
concatenate the material first (requiring the symbol? check, though)
and then
pull the whole thing through the property path checker.  In this case,
it would
appear that you want to call it with #:min 3 #:max 3 #:default 'Bottom
as
anything but a toplevel property would be a cause for problems.

And you should be able to get at your property using (third p) or so.
A similar
recipe should be good for tweaks, just using a different #:start value
for the
check.

OK, that makes sense.  I've rewritten offset according to these
guidelines.  A side benefit
is that it was no trouble to allow directed tweaks, so the following is
possible:

{
  <c'' e'' \offset AccidentalPlacement.right-padding #2 ges''!>4
  <c'' e'' \offset X-offset #-2 ges''!>4
}

Tweaks following tweaks work, too:

{
  <c'' e''
  \offset AccidentalPlacement.right-padding #2
  \offset X-offset #-2 ges''!>4
}

Here's what I come up for offset:

offset =
#(define-music-function (parser location property offsets item)
  (symbol-list-or-symbol? scheme? symbol-list-or-music?)
  (_i "Offset the default value of @var{property} of @var{item} by
@var{offsets}.  If @var{item} is a string, the result is
@code{\\override} for the specified grob type.  If @var{item} is
a music expression, the result is the same music expression with an
appropriate tweak applied.")
  (if (ly:music? item)
      ; In case of a tweak, our grob property path
      ; is Grob.property.
      (let ((prop-path (check-grob-path
                          (if (symbol? property)
                              (list property)
                              property)
                          parser location
                          #:start 1 #:default #t #:min 2 #:max 2)))
        (if prop-path
            ; If the head of the grob property path is a
            ; symbol--i.e., a grob name--produce a directed
            ; tweak.  Otherwise, create an ordinary tweak.
            (if (symbol? (car prop-path))
                #{
                  \tweak #prop-path
                         #(offsetter (second prop-path) offsets) #item
                #}
                #{
                  \tweak #(second prop-path)
                         #(offsetter (second prop-path) offsets) #item
                #})
            (make-music 'Music)))
      ; In case of an override, our grob property path
      ; is Context.Grob.property
      (let ((prop-path (check-grob-path
                          (append item
                                  (if (symbol? property)
                                      (list property)
                                      property))
                          parser location
                          #:default 'Bottom #:min 3 #:max 3)))
        (if prop-path
            #{
              \override #prop-path =
                #(offsetter (third prop-path) offsets)
            #}
            (make-music 'Music)))))

%%%%%%
Thank you very much for your help!



https://codereview.appspot.com/8647044/



reply via email to

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