Output redirection now handles symlinks
[opus_libre.git] / lib / 50-loadthemes.scm
blob7d1a46080a33c5fcebb1d86d3b40c66f8d597996
1 ;------------------------------------------------------------------;
2 ; opus_libre -- 50-loadthemes.scm                                  ;
3 ;                                                                  ;
4 ; (c) 2008-2011 Valentin Villenave <valentin@villenave.net>        ;
5 ;                                                                  ;
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/ ;
16 ;                                                                  ;
17 ;------------------------------------------------------------------;
20 (scm-load "liblayout.scm")
22 (define-public (include-ly dir . hidden?)
23   "Include all LilyPond code found in DIR, recursively.
24  If HIDDEN is set, also load hidden or temporary files."
25   (let* ((regx (if (false-or-null? hidden?)
26                    "/[^\\._][^/]*\\.i?ly$"
27                    ".i?ly$"))
28          (ly-files (find-files dir regx #t)))
29     (map (lambda (x)
30            (if (string-ci=? conf:local-ly-score
31                             (string-take-right x (string-length conf:local-ly-score)))
32                (ly:debug-message "Skipping local score file: ~a..." x)
33                (ly:parser-include-string (format #f "\\include \"~a\"" x))))
34          (reverse ly-files))))
36 (define eval-layout
37   (include-ly conf:layout-dir))
39 (define eval-theme
40 ;;    "Load the default "theme" (that provides basic layout)
41 ;;  then overload user-specified themes (if any) on top of
42 ;;  it."
43   (let* ((default-theme (string-append conf:themes-dir "/" conf:default-theme))
44          (user-theme (if (defined-string? 'theme)
45                          (ly:parser-lookup 'theme)
46                          #f))
47          (include-theme-dir
48           (lambda (dir)
49             (if (exists? dir)
50                 (begin
51                   (ly:debug-message "Loading theme in ~a..." dir)
52                   (load-macros-in dir)
53                   (include-ly dir))
54                 (ly:debug-message "Theme directory not found: ~a."
55                                 f)))))
56     (include-theme-dir default-theme)
57     (if user-theme
58         (if (not (equal? user-theme conf:default-theme))
59             (include-theme-dir
60                      (string-append conf:themes-dir "/" user-theme))))))