[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

chose module name instead of *anonymous-ly-NN*?

From: Nicolas Sceaux
Subject: chose module name instead of *anonymous-ly-NN*?
Date: Sat, 17 Apr 2004 01:08:13 +0200
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)


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?

I'm asking because I was doing the following quick test (with current

--------------- scm/toto.scm -------------------
(define-module (lily))
(export ly:parse-file)
(define-module (scm toto))
(use-modules (ice-9 format) (lily))

(define-public (parse-expression-string str)
  (let ((port (open-output-file "/tmp/")))
    (format port "

vartmp = \\notes { ~a }
#(export vartmp)
#(define-module (scm toto))
#(use-modules (ice-9 format) (*anonymous-ly-15*))

       " str)
    (close-port port)
    (ly:parse-file "/tmp/")

(define-public (read-lily-expression chr port)
  (let ((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))
                           (display c))))))
    `(parse-expression-string ,lily-string)))

(read-hash-extend #\{ read-lily-expression)
--------------- scm/toto.scm -------------------

then, in a lily file:

-------------------- --------------------
#(use-modules (scm toto))
#(define toto #{ <<{e' f'} \\ {c' d'} >> #})
\score { \new Staff { \toto } } 
-------------------- --------------------

ie being able to write a music expression, using LilyPond syntax,
right into a scheme form. This works one time only, as the module
name will change for each new parsed file.

I would like to be able to know what module name write in the
`parse-expression-string' procedure, instead of the hard-coded


PS: It's OK if you don't have time to answer this!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]