RE: Using Scheme inside header markup
> From: Graham Percival [mailto:[EMAIL PROTECTED] > On 12-Jul-05, at 12:43 PM, Sven Axelsson wrote: > > >> There is a little subtlety with options: -dno-comment means > >> that you set > >> the `comment' option to #f, whereas -dcomment means that you > >> set comment > >> to #t. > > > Aargh! That's it alright! Thanks a lot for helping me out here. > > I'm quite interested in this; once you have a working example that > detects command-line options, could you post it here? It'd also > be good to include it in LSR, even if can't display the results of > different command-line options in LSR. :) Sure. Basically it works just as shown in Nicholas Sceaux last mail. In my case I use it to conditionally include extra fields in the header, so I do something like this: \paper { bookTitleMarkup = \markup { % Normal markup for getting the header fields goes here. % Turn my extra field on or off depending on the command line flag. #(ly:export (if (ly:get-option 'show-comment) (markup #:fromproperty 'header:comment) (markup))) } } and then call Lilypond with lilypond -dshow-comment file.ly to turn on the comment field. And as shown in the quoted part above, do not call your option no-comment (or no-whatever), since the getopt library uses that as a toggle for boolean flags. -dcomment is #t, -dno-comment is #f. You can also use use non-boolean defines, like lilypond -dmy-option=43 file.ly and then use the value passed somewhere, like as a parameter to some setting in \page or \layout maybe. -- Sven Axelsson ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Using Scheme inside header markup
On 12-Jul-05, at 12:43 PM, Sven Axelsson wrote: There is a little subtlety with options: -dno-comment means that you set the `comment' option to #f, whereas -dcomment means that you set comment to #t. Aargh! That's it alright! Thanks a lot for helping me out here. I'm quite interested in this; once you have a working example that detects command-line options, could you post it here? It'd also be good to include it in LSR, even if can't display the results of different command-line options in LSR. :) Cheers, - Graham ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
RE: Using Scheme inside header markup
> From: Nicolas Sceaux [mailto:[EMAIL PROTECTED] > Subject: Re: Using Scheme inside header markup > > "Sven Axelsson" <[EMAIL PROTECTED]> writes: > > Now I'm calling lily from a batch file that looks like this > > > > "%ProgramFiles%\lilypond\usr\bin\lilypond.exe" --preview > -dresolution=72 > > -dno-comment %~n1.ly > > "%ProgramFiles%\lilypond\usr\bin\lilypond.exe" --pdf %~n1.ly > > > > And I have this in my header markup: > > > > #(ly:export (if (not (ly:get-option 'no-comment)) > > (markup #:frompropery 'header:comment) > > (markup))) > > > > But I still get the header with the comment field in both cases. > > There is a little subtlety with options: -dno-comment means > that you set > the `comment' option to #f, whereas -dcomment means that you > set comment > to #t. The problem is that, in that case, the comment option > will never > be true: if you say "dno-comment", it will be false, and if you say > nothing, it will be false also. I suggest that you use an option that > does not start by "no-", for instance "-dwithout-comment", > and then you > test (ly:get-option 'without-comment) Aargh! That's it alright! Thanks a lot for helping me out here. Got any idea what's up with the --no-pages option failling? -- Sven Axelsson ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Using Scheme inside header markup
"Sven Axelsson" <[EMAIL PROTECTED]> writes: > Now I'm calling lily from a batch file that looks like this > > "%ProgramFiles%\lilypond\usr\bin\lilypond.exe" --preview -dresolution=72 > -dno-comment %~n1.ly > "%ProgramFiles%\lilypond\usr\bin\lilypond.exe" --pdf %~n1.ly > > And I have this in my header markup: > > #(ly:export (if (not (ly:get-option 'no-comment)) > (markup #:frompropery 'header:comment) > (markup))) > > But I still get the header with the comment field in both cases. There is a little subtlety with options: -dno-comment means that you set the `comment' option to #f, whereas -dcomment means that you set comment to #t. The problem is that, in that case, the comment option will never be true: if you say "dno-comment", it will be false, and if you say nothing, it will be false also. I suggest that you use an option that does not start by "no-", for instance "-dwithout-comment", and then you test (ly:get-option 'without-comment) nicolas ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
RE: Using Scheme inside header markup
> From: Nicolas Sceaux [mailto:[EMAIL PROTECTED] > Subject: Re: Using Scheme inside header markup > > "Sven Axelsson" <[EMAIL PROTECTED]> writes: > > > Great. Now it works that far. What I acually want to do here is to > > detect if Lilypond has been called with the --preview flag and then > > turn off my comment field in the header. > > > > I asked that question some days ago and got this answer > from Han-Wen: > > > >> You could use -dno-verbose-header and then read the > >> result with ly:get-option. > > > > So I thought I just could do > > #(ly:export (if (ly:get-option 'preview) (markup ...))) > > > > but that doesn't work. I get an error "Unknown global option". > > Do you really get an error, or rather a warning? > > > Obviously only a few options are transfered from main.cc > > and preview is not one of them. Han-Wen, how should I do this? > > When invoking lilypond with --preview, add eg. a > -dshort-header option on > the command line. Then, test with ly:get-option whether the > short-header > option is selected or not: > > #(ly:export (if (not (ly:get-option 'short-header)) > (markup #:fromproperty 'header:comment) > (markup))) > > Thus: > $ lilypond --preview -dshort-header myfile.ly > will produce the preview image with short headers, and: > $ lilypond myfile.ly > will produce the score with full headers. Aha! I didn't quite understand how that was supposed to work. Now I'm calling lily from a batch file that looks like this "%ProgramFiles%\lilypond\usr\bin\lilypond.exe" --preview -dresolution=72 -dno-comment %~n1.ly "%ProgramFiles%\lilypond\usr\bin\lilypond.exe" --pdf %~n1.ly And I have this in my header markup: #(ly:export (if (not (ly:get-option 'no-comment)) (markup #:frompropery 'header:comment) (markup))) But I still get the header with the comment field in both cases. Also, I tried --preview --no-pages as suggested in the manual, but then lily fails immediately, producing no output, not even a log file. -- Sven Axelsson ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
RE: Using Scheme inside header markup
> From: Nicolas Sceaux [mailto:[EMAIL PROTECTED] > Subject: Re: Using Scheme inside header markup > > "Sven Axelsson" <[EMAIL PROTECTED]> writes: > > > Lilypond 2.6.0 Windows > > > myCond = ##t > > \paper { > > bookTitleMarkup = \markup { > > \column { > > \fill-line { > > \large \bold \fromproperty #'header:title > > \fromproperty #'header:meter > > \line { \fromproperty #'header:composer " " \italic > > \fromproperty #'header:arranger } > > } > > #(if myCond ( #{\line { \fromproperty > #'header:comment } #} )) > > } > > } > > } > > > [...] but it always gives me a "unknown escaped string" for all the > > backslash expressions at the point right after \header, and > > "unexpected SCM_T" at the #(if statement. > > #{ ... #} is for entering music expressions inside Scheme. > What you want > here is to enter markup expressions. You can do that using the > 'markup' macro. See the LilyPond manual: > http://lilypond.org/doc/v2.6/Documentation/user/out-www/lilypo > nd/Markup-construction-in-Scheme.html Great. Now it works that far. What I acually want to do here is to detect if Lilypond has been called with the --preview flag and then turn off my comment field in the header. I asked that question some days ago and got this answer from Han-Wen: > You could use -dno-verbose-header and then read the > result with ly:get-option. So I thought I just could do #(ly:export (if (ly:get-option 'preview) (markup ...))) but that doesn't work. I get an error "Unknown global option". Obviously only a few options are transfered from main.cc and preview is not one of them. Han-Wen, how should I do this? Thanks -- Sven Axelsson ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Using Scheme inside header markup
"Sven Axelsson" <[EMAIL PROTECTED]> writes: > Lilypond 2.6.0 Windows > myCond = ##t > \paper { > bookTitleMarkup = \markup { > \column { > \fill-line { > \large \bold \fromproperty #'header:title > \fromproperty #'header:meter > \line { \fromproperty #'header:composer " " \italic > \fromproperty #'header:arranger } > } > #(if myCond ( #{\line { \fromproperty #'header:comment } #} )) > } > } > } > [...] but it always gives me a "unknown escaped string" for all the > backslash expressions at the point right after \header, and > "unexpected SCM_T" at the #(if statement. #{ ... #} is for entering music expressions inside Scheme. What you want here is to enter markup expressions. You can do that using the 'markup' macro. See the LilyPond manual: http://lilypond.org/doc/v2.6/Documentation/user/out-www/lilypond/Markup-construction-in-Scheme.html \version "2.7.0" #(define my-cond #f) \paper { bookTitleMarkup = \markup { \column { \fill-line { \large \bold \fromproperty #'header:title \fromproperty #'header:meter \line { \fromproperty #'header:composer " " \italic \fromproperty #'header:arranger } } #(ly:export (if my-cond (markup #:fromproperty 'header:comment) (markup))) } } } \header { title = "Title" meter = "Meter" composer = "Composer" comment = "Comment" } \relative c'' { a b c d } ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user