From c43b641be5e61e66784f5c8eb2ee07ae76abd7e1 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Wed, 20 Mar 2013 13:42:59 +0100 Subject: [PATCH] Simplify interpret-markup-list --- scm/markup.scm | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/scm/markup.scm b/scm/markup.scm index a4f723e04c..9253c378db 100644 --- a/scm/markup.scm +++ b/scm/markup.scm @@ -48,15 +48,16 @@ Example: (define-public interpret-markup ly:text-interface::interpret-markup) (define-public (interpret-markup-list layout props markup-list) - (let ((stencils (list))) - (for-each (lambda (m) - (set! stencils - (if (markup-command-list? m) - (append! (reverse! (apply (car m) layout props (cdr m))) - stencils) - (cons (interpret-markup layout props m) stencils)))) - markup-list) - (reverse! stencils))) + ;; This relies on the markup list returned by a markup list command + ;; to be modifiable + (reverse! + (fold + (lambda (m prev) + (if (markup-command-list? m) + (reverse! (apply (car m) layout props (cdr m)) prev) + (cons (interpret-markup layout props m) prev))) + '() + markup-list))) (define-public (prepend-alist-chain key val chain) (cons (acons key val (car chain)) (cdr chain))) -- 2.39.2