[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ly:context-mod? list to string
From: |
David Kastrup |
Subject: |
Re: ly:context-mod? list to string |
Date: |
Wed, 04 Dec 2013 07:46:22 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
Urs Liska <address@hidden> writes:
> Am 03.12.2013 23:17, schrieb Urs Liska:
>> Am 03.12.2013 20:39, schrieb David Kastrup:
>>> Urs Liska <address@hidden> writes:
>>>
>>>> When I use ly:context-mod? for a parameter in a music function a
>>>> string as the final part will be cut to list items.
>>>>
>>>> if I write
>>>> \function \with { comment = "This should be verified" }
>>>>
>>>> then the ly:context-mod? variable will hold
>>>>
>>>> ((assign comment This should be verified))
>>>>
>>>> cdr-ing makes it (comment This should be verified)
>>>>
>>>> So what's the best (or canonic) way to make that (comment "This should
>>>> be verified") again?
>>> **Bing** Now it is so again.
>>>
>>> More seriously: that's what it always has been. Use "write" instead of
>>> "display" and you'll probably see what you want to.
>>>
>>> If you use format for output, learn about the difference between ~a and
>>> ~s formats.
>>>
>>
>> Thanks for pointing this out.
>> with "write" I indeed see what I want to.
>
> But when I try to pass that to a ly:message I'll get
>
> Wrong type argument in position 1 (expecting string): ("critical-remark")
ly:message expects a string. You are passing it a list. That its first
element is a string does not change that.
The documentation says:
LY_DEFINE (ly_message, "ly:message",
1, 0, 1, (SCM str, SCM rest),
"A Scheme callable function to issue the message @var{str}."
" The message is formatted with @code{format} and @var{rest}.")
So you need a format string here.
You can write (ly:message "~s\n" your-variable) here and get what you
want output in Scheme form. If you don't want strings to be quoted, use
~a instead.
>> Still driving me crazy all this ...
>
> +1
You know you are agreeing with yourself? When in doubt, use
git grep
on the LilyPond code base to find usage examples for functions. I see
address@hidden:/usr/local/tmp/lilypond$ git grep ly:message
Documentation/contributor/programming-work.itexi:@tab @code{(ly:message msg args
input/regression/loglevels.ly:#(ly:message "Test message\n")
lily/warn-scheme.cc:LY_DEFINE (ly_message, "ly:message",
po/zh_TW.po:#. (ly:message (_ "Converting to `~a'...")
scm/backend-library.scm: (ly:message (_ "Converting to `~a'...\n") pdf-name)
scm/backend-library.scm: (ly:message (_ "Converting to ~a...") "PNG")
scm/backend-library.scm: (ly:message (_ "Writing header field `~a' to `~a'...")
scm/documentation-lib.scm: (ly:message (_ "Writing ~S...") x))
scm/framework-eps.scm: (ly:message (_ "Writing ~
scm/framework-svg.scm: (ly:message (_ "Updating font into: ~a") u
scm/graphviz.scm: (ly:message (format #f (_ "Writing graph `~a'...") (port-fi
scm/lily.scm: (else (ly:message ""))))
scm/lily.scm: (ly:message
scm/lily.scm: (ly:message
scm/lily.scm: (ly:message (_ "Redirecting output to ~a...") log-name)
scm/lily.scm: (ly:message "# -*-compilation-*-"))
scm/lily.scm: (ly:message (_ "Invoking `~a'...\n") cmd)
scm/music-functions.scm: (apply ly:message msg rest))))
scm/safe-lily.scm: ly:message
scm/song.scm: (ly:message "Writing Festival XML file ~a..." filename)
scm/song.scm: (apply ly:message message (map pp args))))
scm/stencil.scm: (ly:message "Writing ~a" outname)
anf there are a few examples fitting your use case.
--
David Kastrup