]> git.donarmstrong.com Git - lilypond.git/blob - ly/init.ly
Issue 3153: Let music inside of #{ ... #} originate from @code{location} if set
[lilypond.git] / ly / init.ly
1 %% Toplevel initialisation file. 
2
3 %% switch on debugging.
4 #(if (and #t (defined? 'set-debug-cell-accesses!))
5   (set-debug-cell-accesses! 5000))
6
7 \version "2.16.0"
8
9 #(session-initialize
10   (lambda ()
11    ;; we can't use ly:parser-include-string here since that does not
12    ;; actually do any parsing but merely switches inputs, so the
13    ;; session saved by the session initializer after calling this
14    ;; function has not actually started.  A parser clone, in contrast,
15    ;; can run and complete synchronously and shares the module with
16    ;; the current parser.
17    (ly:parser-parse-string (ly:parser-clone parser)
18     "\\include \"declarations-init.ly\"")))
19
20 #(note-names-language parser default-language)
21
22 #(ly:set-option 'old-relative #f)
23 #(define location #f)
24 #(define toplevel-scores (list))
25 #(define toplevel-bookparts (list))
26 #(define $defaultheader #f)
27 #(define $current-book #f)
28 #(define $current-bookpart #f)
29 #(define version-seen #f)
30 #(define expect-error #f)
31 #(define output-empty-score-list #f)
32 #(define output-suffix #f)
33 #(hash-clear! default-fret-table)
34 #(hash-clear! chord-shape-table)
35 #(hash-clear! musicQuotes)
36
37 #(use-modules (scm clip-region))
38 #(use-modules (srfi srfi-1))
39
40 $(if (ly:get-option 'include-settings)
41   (ly:parser-include-string parser
42     (format #f "\\include \"~a\"" (ly:get-option 'include-settings))))
43
44 \maininput
45 %% there is a problem at the end of the input file
46
47 %%
48 %% Above and below comments compensate for the parser's look-ahead.
49 %%
50
51 #(if (and (ly:get-option 'old-relative)
52       (defined? 'input-file-name)
53       (not (ly:get-option 'old-relative-used)))
54   (old-relative-not-used-message input-file-name))%% there is a problem at the end of the input file
55
56 #(if (and (not version-seen)
57       (defined? 'input-file-name))
58   (version-not-seen-message input-file-name))
59
60 #(ly:set-option 'protected-scheme-parsing #f)
61
62 #(let ((book-handler (if (defined? 'default-toplevel-book-handler)
63                          default-toplevel-book-handler
64                          toplevel-book-handler)))
65    (cond ((pair? toplevel-bookparts)
66           (let ((book (ly:make-book $defaultpaper $defaultheader)))
67             (map (lambda (part)
68                    (ly:book-add-bookpart! book part))
69                  (reverse! toplevel-bookparts))
70             (set! toplevel-bookparts (list))
71             ;; if scores have been defined after the last explicit \bookpart:
72             (if (pair? toplevel-scores)
73                 (map (lambda (score)
74                        (ly:book-add-score! book score))
75                      (reverse! toplevel-scores)))
76             (set! toplevel-scores (list))
77             (book-handler parser book)))
78          ((or (pair? toplevel-scores) output-empty-score-list)
79           (let ((book (apply ly:make-book $defaultpaper 
80                              $defaultheader toplevel-scores)))
81             (set! toplevel-scores (list))
82             (book-handler parser book)))))
83
84 #(if (eq? expect-error (ly:parser-has-error? parser))
85   (ly:parser-clear-error parser)
86   (if expect-error
87    (ly:parser-error parser (_ "expected error, but none found"))))