[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to debug/play with scheme code?
From: |
Nicolas Sceaux |
Subject: |
Re: How to debug/play with scheme code? |
Date: |
Sun, 29 Feb 2004 18:57:42 +0100 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
Sun, 29 Feb 2004 18:06:16 +0100, Matthias a dit :
> I wonder wether there's an easy way to debug scheme code or to get
> something like an interactive scheme interpreter with LilyPond's
> extensions allready loaded. Starting with .ly files isn't very
> convenient.
Some important functions, not to mention music event classes, are
defined in the C++ code. So hacking lily scheme in the guile REPL
would require that lilypond were loaded in it as a shared library, or
something like that. (I once did that but forgot how. something with
libtool). Then, loading scm/lily.scm may be enough (?).
For displaying music expressions, there is a display-music procedure;
this one may also be helpful:
--------------
(use-modules (ice-9 format)
(ice-9 optargs)
(srfi srfi-1))
(define*-public (music-pretty-string obj #:optional (depth 0))
(cond ((ly:music? obj)
(format #f "<~a~{~a~} >"
(ly:music-property obj 'name)
(map (lambda (prop)
(format #f "~%~v_:~a ~a"
(+ 2 (* 13 depth))
(car prop)
(cond ((list? (cdr prop))
(format #f "(~{~a~})"
(map (lambda (mus)
(format #f "~%~v_~a"
(* 13 (1+ depth))
(music-pretty-string mus (1+ depth))))
(cdr prop))))
((string? (cdr prop))
(string-append "\"" (cdr prop) "\""))
(else
(music-pretty-string (cdr prop) (1+
depth))))))
(remove (lambda (prop)
(eqv? (car prop) 'origin))
(ly:get-mutable-properties obj)))))
((string? obj)
(format #f "\"~a\"" obj))
(format #f "~a" obj)))
(define-public (display-music music)
"Pretty print the music expression (for debugging)."
(display (music-pretty-string music)))
--------------
toto=\notes { cis' cis'! cis'? }
#(display-music toto)
===>
<SequentialMusic
:elements (
<EventChord
:elements (
<NoteEvent
:duration #<Duration 4 >
:pitch #<Pitch cis' > >) >
<EventChord
:elements (
<NoteEvent
:force-accidental #t
:duration #<Duration 4 >
:pitch #<Pitch cis' > >) >
<EventChord
:elements (
<NoteEvent
:force-accidental #t
:cautionary #t
:duration #<Duration 4 >
:pitch #<Pitch cis' > >) >) >
nicolas