Nicolas Sceaux writes:
> Is it possible to specify the scheme module name used for declaring
> variables in a LilyPond file? Or is it possible to know what module
> name (the *anonymous-ly-NN*s) will be used the next time a Lily file
> will be parsed?
No, I don't think so, and I'm also not sure if or how we want to do that,
but I've added ly:parse-string (see CVS)
foe.ly:
#(use-modules (scm toetoe))
#(define (textoffset dx dy)
#{ \override Voice.TextScript #'extra-offset = #(cons $dx $dy) #})
myoffset = #(textoffset 3 -4)
\score {
\notes {
c'^"normal text"
%% uhrg, I cannot write scheme here
%% #(textoffset 3 -4)
\myoffset
c'^"text with offset"
}
}
;; toetoe.scm
(define-module (lily))
(define-module (scm toetoe))
(use-modules (ice-9 format) (lily))
(define-public (ly:parse-string-vartmp str)
(ly:parse-string
(format #f "
\\include \"declarations-init.ly\"
%% do nothing special with toplevel music
#(define (toplevel-music-handler x y) (display \"hi\") (newline))
vartmp = \\notes { ~a }
#(export vartmp)
#(define-module (scm toetoe))
#(use-modules (*anonymous-ly-15*))
~%" str))
vartmp)
(define-public (read-lily-expression chr port)
(let* ((format-args '())
(lily-string (with-output-to-string
(lambda ()
(do ((c (read-char port) (read-char port)))
((and (char=? c #\#)
(char=? (peek-char port) #\}))
(read-char port))
(cond ((and (char=? c #\$)
(not (char=? (peek-char port) #\$)))
;; a $variable
(display "~a")
(set! format-args (cons (read port) format-args)))
((and (char=? c #\$)
(char=? (peek-char port) #\$))
;; just a $ character
(display (read-char port)))
(else
;; other caracters
(display c))))))))
`(ly:parse-string-vartmp (format #f ,lily-string ,@(reverse! format-args)))))
(read-hash-extend #\{ read-lily-expression)
--
Jan Nieuwenhuizen <[EMAIL PROTECTED]> | GNU LilyPond - The music typesetter
http://www.xs4all.nl/~jantien | http://www.lilypond.org
_______________________________________________
Lilypond-devel mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/lilypond-devel