]> git.donarmstrong.com Git - lilypond.git/blob - scm/lily.scm
autochange wierdness
[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       0
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)
117   (let*
118       (
119        (fn (%search-load-path x))
120        )
121     (if (ly-verbose)
122         (format (current-error-port) "[~A]" fn))
123     (primitive-load fn)
124
125     ))
126
127
128
129
130 (use-modules (scm tex)
131              (scm ps)
132              (scm pysk)
133              (scm ascii-script)
134              (scm sketch)
135              (scm pdftex)
136              )
137
138 (define output-alist
139   `(
140     ("tex" . ,tex-output-expression)
141     ("ps" . ,ps-output-expression)
142     ("scm" . ,write)
143     ("as" . ,as-output-expression)
144     ("pysk" . ,pysk-output-expression)
145     ("sketch" . ,sketch-output-expression)
146     ("pdftex" . ,pdftex-output-expression)
147 ))
148
149
150 (define (find-dumper format )
151   (let*
152       ((d (assoc format output-alist)))
153     
154     (if (pair?  d)
155                 (cdr d)
156              scm-output-expression)
157             ))
158
159
160 (define X 0)
161 (define Y 1)
162 (define LEFT -1)
163 (define RIGHT 1)
164 (define UP 1)
165 (define DOWN -1)
166 (define CENTER 0)
167
168 (if (not standalone)
169     (map ly-load
170                                         ; load-from-path
171          '("output-lib.scm"
172            "c++.scm"
173            "molecule.scm"
174            "bass-figure.scm"
175            "grob-property-description.scm"
176            "context-description.scm"
177            "interface-description.scm"
178            "beam.scm"
179            "clef.scm"
180            "slur.scm"
181            "font.scm"
182            "music-functions.scm"
183            "music-property-description.scm"
184            "auto-beam.scm"
185            "basic-properties.scm"
186            "chord-name.scm"
187            "grob-description.scm"
188            "translator-property-description.scm"
189            "script.scm"
190            "drums.scm"
191            "midi.scm"
192            )))
193