]> git.donarmstrong.com Git - lilypond.git/blob - scm/lily.scm
8922fef0eaed20729c3dca70db49e167bf9cdd88
[lilypond.git] / scm / lily.scm
1 ;;;; lily.scm -- implement Scheme output routines for TeX and PostScript
2 ;;;;
3 ;;;;  source file of the GNU LilyPond music typesetter
4 ;;;; 
5 ;;;; (c) 1998--2001 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;;; Han-Wen Nienhuys <hanwen@cs.uu.nl>
7
8 ;;; Library functions
9
10 (use-modules (ice-9 regex))
11
12 ;;(write standalone (current-error-port))
13
14 ;;; General settings
15
16
17
18
19 (debug-enable 'backtrace)
20
21
22 (define point-and-click #f)
23 (define security-paranoia #f)
24 (define midi-debug #f)
25
26 (define (line-column-location line col file)
27   "Print an input location, including column number ."
28   (string-append (number->string line) ":"
29                  (number->string col) " " file)
30   )
31
32 (define (line-location line col file)
33   "Print an input location, without column number ."
34   (string-append (number->string line) " " file)
35   )
36
37 ;; cpp hack to get useful error message
38 (define ifdef "First run this through cpp.")
39 (define ifndef "First run this through cpp.")
40   
41 (define default-script-alist '())
42 (define font-name-alist  '())
43
44 (if (not (defined? 'standalone))
45     (define standalone (not (defined? 'ly-gulp-file))))
46
47 ;; The regex module may not be available, or may be broken.
48 (define use-regex
49   (let ((os (string-downcase (vector-ref (uname) 0))))
50     (not (equal? "cygwin" (substring os 0 (min 6 (string-length os)))))))
51
52 ;; If you have trouble with regex, define #f
53 (define use-regex #t)
54 ;;(define use-regex #f)
55
56
57 ;;; Un-assorted stuff
58
59 ;; URG guile-1.4/1.4.x compatibility
60 (if (not (defined? 'primitive-eval))
61     (define (primitive-eval form)
62       (eval2 form #f)))
63
64 (define (sign x)
65   (if (= x 0)
66       1
67       (if (< x 0) -1 1)))
68
69 (define (write-me n x)
70   (display n)
71   (write x)
72   (newline)
73   x)
74
75 (define (empty? x)
76   (equal? x '()))
77
78 (define (!= l r)
79   (not (= l r)))
80
81 (define (filter-list pred? list)
82   "return that part of LIST for which PRED is true."
83   (if (null? list) '()
84       (let* ((rest  (filter-list pred? (cdr list))))
85         (if (pred?  (car list))
86             (cons (car list)  rest)
87             rest))))
88
89 (define (filter-out-list pred? list)
90   "return that part of LIST for which PRED is true."
91   (if (null? list) '()
92       (let* ((rest  (filter-list pred? (cdr list))))
93         (if (not (pred?  (car list)))
94             (cons (car list)  rest)
95             rest))))
96
97 (define (uniqued-alist  alist acc)
98   (if (null? alist) acc
99       (if (assoc (caar alist) acc)
100           (uniqued-alist (cdr alist) acc)
101           (uniqued-alist (cdr alist) (cons (car alist) acc)))))
102
103 (define (uniq-list list)
104   (if (null? list) '()
105       (if (null? (cdr list))
106           list
107           (if (equal? (car list) (cadr list))
108               (uniq-list (cdr list))
109               (cons (car list) (uniq-list (cdr list)))))))
110
111 (define (alist<? x y)
112   (string<? (symbol->string (car x))
113             (symbol->string (car y))))
114
115
116 (define (ly-load x) (eval-string (ly-gulp-file x)))
117
118 (ly-load "output-lib.scm")
119
120
121
122 (use-modules (scm tex)
123              (scm ps)
124              (scm pysk)
125              (scm ascii-script)
126              (scm sketch)
127              )
128
129 (define output-alist
130   `(
131     ("tex" . ,tex-output-expression)
132     ("ps" . ,ps-output-expression)
133     ("scm" . ,write)
134     ("as" . ,as-output-expression)
135     ("pysk" . ,pysk-output-expression)
136     ("sketch" . ,sketch-output-expression)
137 ))
138
139
140
141
142 (define (find-dumper format )
143   (let*
144       ((d (assoc format output-alist)))
145     
146     (if (pair?  d)
147                 (cdr d)
148              scm-output-expression)
149             ))
150
151
152 (if (not standalone)
153     (map ly-load
154                                         ; load-from-path
155          '("output-lib.scm"
156            "sketch.scm"
157            "pdf.scm"
158            "pdftex.scm"
159            "ascii-script.scm"
160            "c++.scm"
161            "grob-property-description.scm"
162            "translator-property-description.scm"
163            "context-description.scm"
164            "interface-description.scm"
165            "beam.scm"
166            "clef.scm"
167            "slur.scm"
168            "font.scm"
169            "music-functions.scm"
170            "music-property-description.scm"
171            "auto-beam.scm"
172            "generic-property.scm"
173            "basic-properties.scm"
174            "chord-name.scm"
175            "grob-description.scm"
176            "script.scm"
177            "drums.scm"
178            "midi.scm"
179            )))
180
181
182