-(define (symbol->tex-key sym)
- (regexp-substitute/global
- #f "_" (output-tex-string (symbol->string sym)) 'pre "X" 'post) )
-
-(define (tex-string-def prefix key str)
- (if (equal? "" (sans-surrounding-whitespace (output-tex-string str)))
- (string-append "\\let\\" prefix (symbol->tex-key key) "\\undefined%\n")
- (string-append "\\def\\" prefix (symbol->tex-key key) "{" (output-tex-string str) "}%\n")
- ))
-
-(define (output-paper-def pd)
- (apply
- string-append
- (module-map
- (lambda (sym var)
- (let
- ((val (variable-ref var))
- (key (symbol->tex-key sym))
- )
-
- (cond
- ((string? val)
- (tex-string-def "lilypondpaper" sym val))
- ((number? val)
- (string-append "\\def\\lilypondpaper" key "{"
- (if (integer? val)
- (number->string val)
- (number->string (exact->inexact val)))
- "}%\n"))
- (else ""))
- ))
-
- (ly:output-def-scope pd))
- ))
-
-(define (output-scopes scopes fields basename)
- (define (output-scope scope)
- (apply
- string-append
- (module-map
- (lambda (sym var)
- (let
- ((val (variable-ref var))
- (tex-key (symbol->string sym))
- )
- (if (memq sym fields)
- (header-to-file basename sym val))
-
- (cond
- ((string? val)
- (tex-string-def "lilypond" sym val) )
- ((number? val)
- (string-append "\\def\\" tex-key "{"
- (if (integer? val)
- (number->string val)
- (number->string (exact->inexact val)))
- "}"))
- (else "") )
-
- ))
- scope)
- ))
-
- (apply string-append
- (map output-scope scopes)) )
-