]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/markup-macros.scm
Doc-es: various updates.
[lilypond.git] / scm / markup-macros.scm
index cccfaccfcba554c5f6f4d207ffd69bc0ec7a70a1..6c50ec51280e614796229fd565401b9474d16d07 100644 (file)
@@ -1,6 +1,6 @@
 ;;;; This file is part of LilyPond, the GNU music typesetter.
 ;;;;
-;;;; Copyright (C) 2003--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
+;;;; Copyright (C) 2003--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
 ;;;;
 ;;;; LilyPond is free software: you can redistribute it and/or modify
 ;;;; it under the terms of the GNU General Public License as published by
@@ -110,14 +110,14 @@ command.  There is no protection against circular definitions.
            (set! body (cddr body)))
     `(begin
        ;; define the COMMAND-markup function
-       ,(let* ((documentation (if (string? (car body))
-                                  (list (car body))
-                                  '()))
-               (real-body (if (or (null? documentation)
+       ,(let* ((documentation
+                (format #f "~a\n~a" (cddr args)
+                        (if (string? (car body)) (car body) "")))
+               (real-body (if (or (not (string? (car body)))
                                   (null? (cdr body)))
                               body (cdr body))))
           `(define-public (,command-name ,@args)
-             ,@documentation
+             ,documentation
              (let ,(map (lambda (prop-spec)
                           (let ((prop (car prop-spec))
                                 (default-value (if (null? (cdr prop-spec))
@@ -147,7 +147,7 @@ command.  There is no protection against circular definitions.
                                         ((not (null? (cdr prop-spec)))
                                          `(list ',(car prop-spec) ,(cadr prop-spec)))
                                         (else
-                                          `(list ',(car prop-spec)))))
+                                         `(list ',(car prop-spec)))))
                                 (if (pair? args)
                                     properties
                                     (list)))))
@@ -168,14 +168,14 @@ interpreted, returns a list of stencils instead of a single one"
            (set! body (cddr body)))
     `(begin
        ;; define the COMMAND-markup-list function
-       ,(let* ((documentation (if (string? (car body))
-                                  (list (car body))
-                                  '()))
-               (real-body (if (or (null? documentation)
+       ,(let* ((documentation
+                (format #f "~a\n~a" (cddr args)
+                        (if (string? (car body)) (car body) "")))
+               (real-body (if (or (not (string? (car body)))
                                   (null? (cdr body)))
                               body (cdr body))))
           `(define-public (,command-name ,@args)
-             ,@documentation
+             ,documentation
              (let ,(map (lambda (prop-spec)
                           (let ((prop (car prop-spec))
                                 (default-value (if (null? (cdr prop-spec))
@@ -197,7 +197,7 @@ interpreted, returns a list of stencils instead of a single one"
                                         ((not (null? (cdr prop-spec)))
                                          `(list ',(car prop-spec) ,(cadr prop-spec)))
                                         (else
-                                          `(list ',(car prop-spec)))))
+                                         `(list ',(car prop-spec)))))
                                 (if (pair? args)
                                     properties
                                     (list)))))
@@ -236,11 +236,11 @@ interpreted, returns a list of stencils instead of a single one"
 ;;;;;;;;;;;;;;;;;;;;;;
 ;;; markup type predicates
 
-(define (markup-function? x)
+(define-public (markup-function? x)
   (and (markup-command-signature x)
        (not (object-property x 'markup-list-command))))
 
-(define (markup-list-function? x)
+(define-public (markup-list-function? x)
   (and (markup-command-signature x)
        (object-property x 'markup-list-command)))
 
@@ -344,11 +344,6 @@ against SIGNATURE, reporting MAKE-NAME as the user-invoked function.
 
 (use-modules (ice-9 receive))
 
-(defmacro*-public markup* (#:rest body)
-  "Same as `markup', for use in a \\notes block."
-  `(ly:export (markup ,@body)))
-
-
 (define (compile-all-markup-expressions expr)
   "Return a list of canonical markups expressions, e.g.:
   (#:COMMAND1 arg11 arg12 #:COMMAND2 arg21 arg22 arg23)
@@ -389,10 +384,10 @@ against SIGNATURE, reporting MAKE-NAME as the user-invoked function.
                       (set! args (cons `(list ,@(compile-all-markup-expressions (car rest))) args))
                       (set! rest (cdr rest)))
                      (else
-                       ;; pick up one arg in `rest'
-                       (receive (a r) (compile-markup-arg rest)
-                                (set! args (cons a args))
-                                (set! rest r))))))))
+                      ;; pick up one arg in `rest'
+                      (receive (a r) (compile-markup-arg rest)
+                               (set! args (cons a args))
+                               (set! rest r))))))))
         ((and (pair? expr)
               (pair? (car expr))
               (keyword? (caar expr)))
@@ -403,9 +398,9 @@ against SIGNATURE, reporting MAKE-NAME as the user-invoked function.
               (string? (car expr))) ;; expr === ("string" ...)
          (values `(make-simple-markup ,(car expr)) (cdr expr)))
         (else
-          ;; expr === (symbol ...) or ((funcall ...) ...)
-          (values (car expr)
-                  (cdr expr)))))
+         ;; expr === (symbol ...) or ((funcall ...) ...)
+         (values (car expr)
+                 (cdr expr)))))
 
 (define (compile-all-markup-args expr)
   "Transform `expr' into markup arguments"
@@ -459,21 +454,3 @@ against SIGNATURE, reporting MAKE-NAME as the user-invoked function.
                (string->symbol (format #f "~a-markup-list" code)))))
     (and proc (markup-list-function? proc)
          (cons proc (markup-command-signature proc)))))
-
-;;;;;;;;;;;;;;;;;;;;;;
-;;; used in parser.yy to map a list of markup commands on markup arguments
-(define-public (map-markup-command-list 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))))
-"
-  (map-in-order (lambda (arg)
-                  (let ((result arg))
-                    (for-each (lambda (cmd)
-                                (set! result (append cmd (list result))))
-                              commands)
-                    result))
-                markups))