1 ;------------------------------------------------------------------;
2 ; opus_libre -- 40-loadmacros.scm ;
4 ; (c) 2008-2011 Valentin Villenave <valentin@villenave.net> ;
6 ; opus_libre is a free framework for GNU LilyPond: you may ;
7 ; redistribute it and/or modify it under the terms of the GNU ;
8 ; General Public License as published by the Free Software ;
9 ; Foundation, either version 3 of the License, or (at your option) ;
10 ; any later version. ;
11 ; This program is distributed WITHOUT ANY WARRANTY; without ;
12 ; even the implied warranty of MERCHANTABILITY or FITNESS FOR A ;
13 ; PARTICULAR PURPOSE. You should have received a copy of the GNU ;
14 ; General Public License along with this program (typically in the ;
15 ; share/doc/ directory). If not, see http://www.gnu.org/licenses/ ;
17 ;------------------------------------------------------------------;
21 (defmacro make-function (token funct)
22 (let* ((sym (if (defined-string? token)
23 (string->symbol (primitive-eval token))
25 `(define-public ,sym ,funct)))
28 (defmacro staff-change-command (token)
29 (let* ((str (primitive-eval token))
30 (sym (if (defined-string? token)
34 (define-music-function (parser location) ()
35 (make-music 'ContextChange 'change-to-type 'Staff
36 'change-to-id ,str)))))
38 (defmacro make-script (str)
39 (let* ((sym (car (primitive-eval str)))
40 (script (cdr (primitive-eval str))))
42 (define-music-function (parser location mus) (ly:music?)
43 (add-script mus ,script)))))
46 ;; Not used. See make-script above.
47 (define (make-scripts lst)
52 (set! lst (car lst))))
55 (eval-string (format #f
56 ;; hackish, but oh sooo convenient
58 (define-music-function (parser location mus) (ly:music?)
59 (add-script mus \"~a\")))" sym script)))
60 (if (not-null? rest) (make-scripts rest))))
62 (define (load-macros-in dir)
65 (ly:debug-message "Loading macros file ~a..." x)
67 (scm-load (string-append "../" x))))
68 (find-files dir ".scm$")))
71 ;; "Load macros, first at a global level
72 ;; (typically in bin/), then locally (which
73 ;; allows the score to override some definitions
76 (load-macros-in conf:macros-dir)
77 (load-macros-in conf:local-conf-dir)))