]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3932: Clean up code for sorting grob-properties.
authorMark Polesky <markpolesky@yahoo.com>
Mon, 2 Jun 2014 22:31:35 +0000 (15:31 -0700)
committerMark Polesky <markpolesky@yahoo.com>
Mon, 2 Jun 2014 22:31:35 +0000 (15:31 -0700)
scm/document-backend.scm

index 80ba17a3ba34cd1958f80fa6b72bae234613c008..e311695005365883a84d2ad23c73bb0020df0d87 100644 (file)
 ;;;; You should have received a copy of the GNU General Public License
 ;;;; along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
 
-(define (sort-grob-properties x)
+(define (sort-grob-properties props)
   ;; force 'meta to the end of each prop-list
-  (let ((meta (assoc 'meta x)))
-    (append (sort (assoc-remove! x 'meta) ly:alist-ci<?)
+  (let ((meta (assoc 'meta props)))
+    (append (sort (assoc-remove! props 'meta) ly:alist-ci<?)
             (list meta))))
 
-;; properly sort all grobs, properties, and interfaces
+;; properly sort all properties and interfaces
 ;; within the all-grob-descriptions alist
-(for-each
- (lambda (x)
-   (let* ((props      (assoc-ref all-grob-descriptions (car x)))
-          (meta       (assoc-ref props 'meta))
-          (interfaces (assoc-ref meta 'interfaces)))
-     (set! all-grob-descriptions
-           (sort (assoc-set! all-grob-descriptions (car x)
-                             (sort-grob-properties
-                              (assoc-set! props 'meta
-                                          (assoc-set! meta 'interfaces
-                                                      (sort interfaces ly:symbol-ci<?)))))
-                 ly:alist-ci<?))))
- all-grob-descriptions)
+(set! all-grob-descriptions
+  (map!
+    (lambda (grob-description)
+      (let* ((grob-key      (car grob-description))
+             (props         (assoc-ref all-grob-descriptions grob-key))
+             (meta          (assoc-ref props 'meta))
+             (interfaces    (assoc-ref meta 'interfaces))
+             (sorted-ifaces (sort interfaces ly:symbol-ci<?))
+             (new-meta      (assoc-set! meta 'interfaces sorted-ifaces))
+             (new-props     (assoc-set! props 'meta new-meta))
+             (sorted-props  (sort-grob-properties new-props)))
+        (cons grob-key sorted-props)))
+    all-grob-descriptions))
+
+;; sort all grobs in the all-grob-descriptions alist
+(set! all-grob-descriptions (sort all-grob-descriptions ly:alist-ci<?))
 
 (define (interface-doc-string interface grob-description)
   (let* ((name (car interface))