Hallo Erich,
LilyPond hat zwar einige display procedures, aber Deine Frage zielt ja auf die scheme-procedure write ab.
Und ich denke Du meinst nicht die Möglichkeiten, die man im Terminal hat den output auszugeben!?
Tatsächlich hat write (wie auch display und andere) ein optionales Argument mit dem man den output "umleiten" kann.
Ich habe es jetzt so gemacht, daß ich eine verallgemeinerte Definition geschrieben habe, die man benutzen kann, um eigene Ausgabe-funktionen zu erstellen.
Kommentare und Beispiel im Code.
Das file log.txt aus dem Beispiel wird (falls noch nicht vorhanden) in dem Ordner erschaffen in dem Du Dich gerade befindest.
Das Ganze ist so gesetzt, daß es aus einem LilyPond-file heraus funktioniert.
Wenn etwas unklar ist melde Dich.
#(define* ((my-write #:optional (port (current-output-port))
(option "a") ;; or "w"
(write-proc display))
arg)
;; my-write is meant as a general custom-definition of write/display etc
;; to make other custom-definitions possible quite easily
;;
;; optional arguments are
;; port - defaults to the terminal on most systems
;; can be set to a file-name-string
;; option - default "a" means the output is appended
;; "w" means the file content will be overriden
;; Only used if port is not the default
;; write-proc - defaults to display
;; other possible settings are write or
;; pretty-print (with the need use the relevant modules)
;;
;; (my-write) without any specification is pretty much the same as display with
;; an added (newline)
(let* ((port (if (eq? (current-output-port) port)
port
(open-file port option))))
(write-proc arg port)
(newline port)
(if (not (eq? (current-output-port) port))
(close port))))
%% Example-definition:
% Need to set the following to make pretty-print possible
#(use-modules (ice-9 pretty-print))
#(define (write-to-log arg)
((my-write "log.txt" "a" pretty-print) arg))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXAMPLES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#(write-to-log "blabla")
%#(write-to-log all-user-grob-properties)
HTH,
Harm