[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: helper function that should take a list argument doesn't do anything
From: |
David Kastrup |
Subject: |
Re: helper function that should take a list argument doesn't do anything |
Date: |
Thu, 08 Nov 2012 09:21:11 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) |
Janek Warchoł <address@hidden> writes:
> % Hi people,
>
> % here's what i want to do:
>
> <<
> {
> \overrideProperty #"Score.NonMusicalPaperColumn"
> #'line-break-system-details #'((alignment-distances . (30)))
> a a a a
> }
> { b b b b }
>>>
>
> % the override is very long, so i wanted to create a helper music
> function. I tried this
>
> staffdist =
> #(define-music-function (parser location distances)
> (list?)
> #{
> \overrideProperty #"Score.NonMusicalPaperColumn"
> #'line-break-system-details
> #'((alignment-distances . #'distances))
> #})
> I don't see any example function operating on lists in the Extending
> manual, so i'm a bit lost. I had no problem with a similar function
> which operates on a pair and overrides beam positions. I have no idea
> why this doesn't work.
>
> what i'm doing wrong?
Quite a bit.
First, let's assume 2.16 (the current development version will not
accept the above syntax of \overrideProperty even in the first variant).
Then inside of # itself, like with #'((alignement-distances ..., # has
only Scheme meanings, like #t, #f, #(2 3 4) (a literal vector), #{
... #} (embedded LilyPond), #\? (a character constant). #' is not
anything it recognizes I think.
Then you are writing a quoted list here. Inside of a quoted list, _all_
symbols are quoted, not referenced for their value. So you need either
to use proper evaluated Scheme here, like
#(list (cons 'alignment-distances distances))
or quasi-quoting (backtick at the start, evaluated stuff with , before
it), like
#`((alignment-distances . ,distances))
I am not entirely sure that . , is accepted, but if it isn't,
#`((alignment-distances ,@distances))
should do the trick instead (,@ is the list splicing operator, basically
stripping one level of parens when inserting).
--
David Kastrup