[Top][All Lists]

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

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

From: Jan Nieuwenhuizen
Subject: Re: chose module name instead of *anonymous-ly-NN*?
Date: Wed, 21 Apr 2004 10:58:55 +0200
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

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)
#(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)

        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)
     (format #f "
\\include \"\"
%% 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))

(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) 
                                  ((and (char=? c #\$)
                                        (char=? (peek-char port) #\$))
                                   ;; just a $ character
                                   (display (read-char port)))
                                   ;; other caracters
                                   (display c))))))))
    `(ly:parse-string-vartmp (format #f ,lily-string ,@(reverse! 

(read-hash-extend #\{ read-lily-expression)

Jan Nieuwenhuizen <address@hidden> | GNU LilyPond - The music typesetter       |

reply via email to

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