]> git.donarmstrong.com Git - lilypond.git/blob - ly/init.ly
Web-ja: update introduction
[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.19.22"
8
9 #(if (guile-v2)
10   (use-modules (ice-9 curried-definitions)))
11
12 #(session-initialize
13   (lambda ()
14    ;; we can't use ly:parser-include-string here since that does not
15    ;; actually do any parsing but merely switches inputs, so the
16    ;; session saved by the session initializer after calling this
17    ;; function has not actually started.  A parser clone, in contrast,
18    ;; can run and complete synchronously and shares the module with
19    ;; the current parser.
20    (ly:parser-parse-string (ly:parser-clone)
21     "\\include \"declarations-init.ly\"")))
22
23 #(note-names-language default-language)
24
25 #(define toplevel-scores (list))
26 #(define toplevel-bookparts (list))
27 #(define $defaultheader #f)
28 #(define $current-book #f)
29 #(define $current-bookpart #f)
30 #(define version-seen #f)
31 #(define expect-error #f)
32 #(define output-empty-score-list #f)
33 #(define output-suffix #f)
34
35 #(use-modules (scm clip-region))
36 #(use-modules (srfi srfi-1))
37 #(use-modules (ice-9 pretty-print))
38
39 $(if (ly:get-option 'include-settings)
40   (ly:parser-include-string
41     (format #f "\\include \"~a\"" (ly:get-option 'include-settings))))
42
43 \maininput
44 %% there is a problem at the end of the input file
45
46 %%
47 %% Above and below comments compensate for the parser's look-ahead.
48 %%
49
50 #(if (and (not version-seen)
51       (defined? 'input-file-name))
52   (version-not-seen-message input-file-name))
53
54 #(ly:set-option 'protected-scheme-parsing #f)
55
56 #(let ((book-handler (if (defined? 'default-toplevel-book-handler)
57                          default-toplevel-book-handler
58                          toplevel-book-handler)))
59    (cond ((pair? toplevel-bookparts)
60           (let ((book (ly:make-book $defaultpaper $defaultheader)))
61             (for-each (lambda (part)
62                         (ly:book-add-bookpart! book part))
63                       (reverse! toplevel-bookparts))
64             (set! toplevel-bookparts (list))
65             ;; if scores have been defined after the last explicit \bookpart:
66             (if (pair? toplevel-scores)
67                 (for-each (lambda (score)
68                             (ly:book-add-score! book score))
69                           (reverse! toplevel-scores)))
70             (set! toplevel-scores (list))
71             (book-handler book)))
72          ((or (pair? toplevel-scores) output-empty-score-list)
73           (let ((book (apply ly:make-book $defaultpaper
74                              $defaultheader toplevel-scores)))
75             (set! toplevel-scores (list))
76             (book-handler book)))))
77
78 #(if (eq? expect-error (ly:parser-has-error?))
79   (ly:parser-clear-error)
80   (if expect-error
81    (ly:parser-error (_ "expected error, but none found"))))