4

I'm trying to use the code from a snippet found on the official documentation on "Displaying pitches" (scroll down to "Known issues and warnings"):

\version "2.18.2"

forget = #(define-music-function (music) (ly:music?) #{
  \accidentalStyle forget
  #music
  \accidentalStyle modern
#})
{
  \accidentalStyle modern
  \time 2/4
  \repeat volta 2 {
    c'2
  }
  \alternative {
     \repeat volta 1 { cis' }
     \repeat volta 2 { \forget c' }
  }
}

When I compile it, I get the following error:

Changing working directory to: `/tmp'
Processing `/tmp/11678868158475380898.ly'
Parsing.../usr/share/lilypond/2.18.2/scm/ly-syntax-constructors.scm:56:23: In expression (apply (ly:music-function-extract fun) parser ...):
/usr/share/lilypond/2.18.2/scm/ly-syntax-constructors.scm:56:23: Wrong number of arguments to #<procedure #f (music)>

I get a similar error when trying other substitution functions, e.g. the ones provided here. I'm not familiar with Scheme so I can't really debug/analyze what I'm doing wrong.

I'm using Lilypond 2.18.2 on a Raspberry Pi, if that matters.

2 Answers 2

7

When using examples from the manual for version 2.23 for LilyPond version 2.18, you may expect some things not to work.

However you arrived at that link, try replacing the v2.23 string in its URL with v2.18 and take your example code from there.

1
  • 1
    To be honest, I didn't expect such major structural changes (given how mature Lilypond is already). Indeed, I had to replace (music) with (parser location music) and now it works.
    – Glorfindel
    Nov 7, 2021 at 19:15
2

It's worth pointing out that the code in the LilyPond manual produces the printed results directly in the process of creating the documentation HTML and PDF files. That means that there is no code with printed results whatsoever that would "accidently" fail to compile absolutely as-is with the version corresponding to the manual. What may happen is that the printed results differs from what you'd expect from the text description: in this case, this may be a documentation bug. But it cannot happen that it fails to compile at all or produces a different visual result, as long as you are using the correct version.

You have also altered contents of \alternative, replacing it by something syntactically valid for 2.18 but contextually nonsensical, producing an absurd printed result.

1
  • Yeah, thanks for the warning. That's what happens if you a few try things before submitting your code to Stack Exchange... I thought Lilypond might not recognize the main block as a music expression since it lacks a \relative command. (I knew about absolute notation, but thought you'd need to declare that specifically as well.)
    – Glorfindel
    Nov 8, 2021 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.