;; 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
;; 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)
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)
'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)
(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)))