X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fly-syntax-constructors.scm;h=7817ec25c5ddee138681eed94ca77b5ec8f3490c;hb=528e1aac95928f3fbe017af0b3d7a0f0a0ccafbf;hp=0fe9aa0f7839db0d37f05debac77f4bf63f4a63d;hpb=b2d3e79a146de7cb2eb2be722a510c0e4fc90fa8;p=lilypond.git diff --git a/scm/ly-syntax-constructors.scm b/scm/ly-syntax-constructors.scm index 0fe9aa0f78..7817ec25c5 100644 --- a/scm/ly-syntax-constructors.scm +++ b/scm/ly-syntax-constructors.scm @@ -1,6 +1,6 @@ ;;;; This file is part of LilyPond, the GNU music typesetter. ;;;; -;;;; Copyright (C) 2006--2011 Erik Sandberg +;;;; Copyright (C) 2006--2012 Erik Sandberg ;;;; ;;;; LilyPond is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by @@ -18,7 +18,7 @@ ;; TODO: use separate module for syntax ;; constructors. Also create wrapper around the constructor? (defmacro define-ly-syntax (args . body) - `(define-public ,args ,(cons 'begin body))) + `(define-public ,args ,@body)) ;; A ly-syntax constructor takes two extra parameters, parser and ;; location. These are mainly used for reporting errors and @@ -50,10 +50,11 @@ ;; we don't call the function but rather return the general ;; fallback. (define-ly-syntax (music-function parser loc fun args . rest) - (let* ((sig (object-property fun 'music-function-signature)) + (let* ((sig (ly:music-function-signature fun)) (pred (if (pair? (car sig)) (caar sig) (car sig))) (good (proper-list? args)) - (m (and good (apply fun parser loc (reverse! args rest))))) + (m (and good (apply (ly:music-function-extract fun) + parser loc (reverse! args rest))))) (if (and good (pred m)) (begin (if (ly:music? m) @@ -140,16 +141,8 @@ into a @code{MultiMeasureTextEvent}." (if (memq 'script-event (ly:music-property music 'types)) - (let* ((location (ly:music-property music 'origin)) - (dir (ly:music-property music 'direction)) - (tags (ly:music-property music 'tags)) - (p (make-music 'MultiMeasureTextEvent - 'origin location - 'tags tags - 'text (ly:music-property music 'text)))) - (if (ly:dir? dir) - (set! (ly:music-property p 'direction) dir)) - p) + (apply make-music 'MultiMeasureTextEvent + (flatten-alist (ly:music-mutable-properties music))) music)) (define-ly-syntax (multi-measure-rest parser location duration articulations) @@ -158,10 +151,10 @@ into a @code{MultiMeasureTextEvent}." 'duration duration 'origin location)) -(define-ly-syntax (repetition-chord parser location previous-chord repetition-function duration articulations) - (make-music 'RepeatedChord - 'original-chord previous-chord - 'element (repetition-function previous-chord location duration articulations) +(define-ly-syntax (repetition-chord parser location duration articulations) + (make-music 'EventChord + 'duration duration + 'elements articulations 'origin location)) (define-ly-syntax-simple (context-specification type id ops create-new mus) @@ -171,6 +164,33 @@ into a @code{MultiMeasureTextEvent}." (if create-new (set! (ly:music-property csm 'create-new) #t)) csm)) +(define-ly-syntax (composed-markup-list parser location commands markups) +;; `markups' being a list of markups, eg (markup1 markup2 markup3), +;; and `commands' a list of commands with their scheme arguments, in reverse order, +;; eg: ((italic) (raise 4) (bold)), maps the commands on each markup argument, eg: +;; ((bold (raise 4 (italic markup1))) +;; (bold (raise 4 (italic markup2))) +;; (bold (raise 4 (italic markup3)))) + + (define (compose arg) + (fold + (lambda (cmd prev) (append cmd (list prev))) + arg + commands)) + (let loop ((markups markups) (completed '())) + (cond ((null? markups) (reverse! completed)) + ((markup? (car markups)) + (loop (cdr markups) + (cons (compose (car markups)) completed))) + (else + (call-with-values + (lambda () (break! markup? markups)) + (lambda (complex rest) + (loop rest + (reverse! + (make-map-markup-commands-markup-list + compose complex) completed)))))))) + (define-ly-syntax (property-operation parser location ctx music-type symbol . args) (let* ((props (case music-type ((PropertySet) (list 'value (car args)))