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)))
27 (defmacro staff-change-command (token)
28 (let* ((str (primitive-eval token))
29 (sym (if (defined-string? token)
33 (define-music-function () ()
34 (make-music 'ContextChange 'change-to-type 'Staff
35 'change-to-id ,str)))))
37 (defmacro make-script (str)
38 (let* ((sym (car (primitive-eval str)))
39 (script (cdr (primitive-eval str))))
41 (define-music-function (mus) (ly:music?)
42 (add-script mus ,script)))))
45 ;; Not used. See make-script above.
46 (define (make-scripts lst)
51 (set! lst (car lst))))
54 (eval-string (format #f
55 ;; hackish, but oh sooo convenient
57 (define-music-function (mus) (ly:music?)
58 (add-script mus \"~a\")))" sym script)))
59 (if (not-null? rest) (make-scripts rest))))
61 (define (load-macros-in dir)
64 (ly:debug-message "Loading macros file ~a..." x)
66 (scm-load (string-append "../" x))))
67 (find-files dir ".scm$")))
70 ;; "Load macros, first at a global level
71 ;; (typically in bin/), then locally (which
72 ;; allows the score to override some definitions
75 (load-macros-in conf:macros-dir)
76 (load-macros-in conf:local-conf-dir)))