]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/predefined-fretboards.scm
Add '-dcrop' option to ps and svg backends
[lilypond.git] / scm / predefined-fretboards.scm
index 5140ae6e91093e0a7f8a92ba94a76b7bcba8330e..5f4d7005cd518af052ee8d7bee690ce5d5529be7 100644 (file)
@@ -1,6 +1,6 @@
 ;;;; This file is part of LilyPond, the GNU music typesetter.
 ;;;;
-;;;; Copyright (C) 2008--2012 Carl D. Sorensen <c_sorensen@byu.edu>
+;;;; Copyright (C) 2008--2015 Carl D. Sorensen <c_sorensen@byu.edu>
 ;;;;
 ;;;; LilyPond is free software: you can redistribute it and/or modify
 ;;;; it under the terms of the GNU General Public License as published by
@@ -38,20 +38,17 @@ and return a marking list, which can be used with a fretboard grob."
          (if (string? diagram-definition)
              (parse-terse-string diagram-definition)
              diagram-definition)))
-    (map (lambda(item)
-           (let ((code (car item)))
-             (cond
-              ((eq? code 'barre)
-               (list-set! item 3
-                          (+ fret-offset (list-ref item 3)))
-               item)
-              ((eq? code 'capo)
-               (list-set! item 1
-                          (+ fret-offset (list-ref item 1)))
-               item)
-              ((eq? code 'place-fret)
-               (list-set! item 2
-                          (+ fret-offset (list-ref item 2)))
-               item)
-              (else item))))
+    (map (lambda (item)
+           (let* ((code (car item))
+                  (nth (assq-ref '((barre . 3) (capo . 1) (place-fret . 2))
+                                 code)))
+             (if nth
+                 ;; offset nth element of item by offset-fret
+                 ;; without modifying the original list but
+                 ;; sharing its tail
+                 (let ((tail (list-tail item nth)))
+                   (append! (list-head item nth)
+                            (cons (+ (car tail) fret-offset)
+                                  (cdr tail))))
+                 item)))
          verbose-definition)))