\version "2.9.17" #(define output (open-output-file "graph.dot")) #(define node-num 0) #(define last-grob-action '()) #(define sym-blacklist '(cause font)) #(define sym-whitelist '(left-neighbors right-neighbors left-items right-items)) #(define file-line-blacklist '()) #(define file-line-whitelist '()) % an event is relevant if % (it is on some whitelist or all whitelists are empty) % and % (it isn't on any blacklist) #(define (relevant? grob file line prop) (let ((file-line `(,file . ,line))) (and (or (= 0 (length file-line-whitelist) (length sym-whitelist)) (memq prop sym-whitelist) (member file-line file-line-whitelist)) (and (not (memq prop sym-blacklist)) (not (member file-line file-line-blacklist)))))) #(display "digraph G {\nrankdir=\"LR\"\nnode [shape=rectangle]\n" output) #(define (grob-mod grob file line prop val) (let* ((prev (assv grob last-grob-action)) (val-str0 (format "~a" val)) (val-str (string-take val-str0 (min 50 (string-length val-str0))))) (if (relevant? grob file line prop) (begin (display (format "~a [label=\"~a\\n~a:~a\\n~a <- ~a\"]\n" node-num grob file line prop val-str) output) (display (format "subgraph cluster_~a {\nlabel = \"~a\"\ncolor=blue\n~a\n}\n" (string-filter file char-alphabetic?) file node-num) output) (if (pair? prev) (display (format "~a -> ~a\n" (cdr prev) node-num) output)) (set! last-grob-action (assv-set! last-grob-action grob node-num)) (set! node-num (1+ node-num)))))) #(define (grob-create grob file line) (display (format "~a [label=\"~a\\n~a:~a\",color=green]\n" node-num grob file line) output) (display (format "subgraph cluster_~a {\nlabel = \"~a\"\ncolor=blue\n~a\n}\n" (string-filter file char-alphabetic?) file node-num) output) (set! last-grob-action (assv-set! last-grob-action grob node-num)) (set! node-num (1+ node-num))) #(ly:set-grob-modification-callback grob-mod) #(ly:set-grob-creation-callback grob-create) { a b c d a b c d }