]> git.donarmstrong.com Git - lilypond.git/blob - scm/lily.scm
memory tracing refinements.
[lilypond.git] / scm / lily.scm
1 ;;;; lily.scm -- toplevel Scheme stuff
2 ;;;;
3 ;;;;  source file of the GNU LilyPond music typesetter
4 ;;;; 
5 ;;;; (c) 1998--2006 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;;; Han-Wen Nienhuys <hanwen@xs4all.nl>
7
8 ;; Internationalisation: (_i "to be translated") gets an entry in the
9 ;; POT file (gettext ) must be invoked explicitely to do the actual
10 ;; "translation".
11 ;;(define-macro (_i x) x)
12 ;;(define-macro-public _i (x) x)
13 ;;(define-public-macro _i (x) x)
14 ;; Abbrv-PWR!
15 (defmacro-public _i (x) x)
16
17 (read-enable 'positions)
18 (debug-enable 'debug)
19
20
21 (define (define-scheme-options)
22   (for-each (lambda (x)
23               (ly:add-option (car x) (cadr x) (caddr x)))
24           
25             `(
26
27               ;; NAMING: either
28
29               ;; - [subject-]object-object-verb +"ing"
30               ;; - [subject-]-verb-object-object
31
32               (anti-alias-factor 1 "render at higher resolution and scale down result\nto prevent jaggies in PNG")
33               (check-internal-types #f "check every property assignment for types")
34               (clip-systems #f "Generate cut-out snippets of a score")
35               (debug-gc #f "dump memory debugging statistics")
36               (debug-gc-assert-parsed-dead #f "for memory debugging:
37 ensure that all refs to parsed objects are dead.  This is an internal option, and is switched on automatically for -ddebug-gc.") 
38               (debug-lexer #f "debug the flex lexer")
39               (debug-parser #f "debug the bison parser")
40               (debug-skylines #f "debug skylines")
41               (delete-intermediate-files #f
42                                          "delete unusable PostScript files")
43               (dump-profile #f "dump timing information for each file")
44               (dump-signatures #f "dump output signatures of each system.  Used for regression testing.")
45               
46               (eps-box-padding #f "Pad EPS bounding box left edge.  Guarantee alignment between systems in LaTeX.")
47               (gs-load-fonts #f
48                             "load fonts via Ghostscript.")
49               (gui #f "running from gui; redirect stderr to log file")
50
51               (include-book-title-preview #t "include book-titles in preview images.")
52               (include-eps-fonts #t "Include fonts in separate-system EPS files.")
53               (job-count #f "Process in parallel") 
54               (log-file #f "redirect output to log FILE.log")
55
56               (old-relative #f
57                             "relative for simultaneous music works
58 similar to chord syntax")
59               (point-and-click #t "use point & click")
60               (paper-size "a4" "the default paper size")
61               (pixmap-format "png16m" "GS format to use for pixel images")
62               (protected-scheme-parsing #t "continue when finding errors in inline
63 scheme are caught in the parser. If off, halt 
64 on errors, and print a stack trace.")
65               (profile-property-accesses #f "keep statistics of get_property() calls.")
66               
67               (resolution 101 "resolution for generating PNG bitmaps")
68               (read-file-list #f "Read files to be processed from command line arguments")
69
70               (safe #f "Run safely")
71               (strict-infinity-checking #f "If yes, crash on encountering Inf/NaN.")
72               (separate-log-files #f "Output to FILE.log per file.")
73               (trace-memory-frequency #f "Record Scheme cell usage this many times per second, and dump to file.")
74               (ttf-verbosity 0
75                              "how much verbosity for TTF font embedding?")
76               (show-available-fonts #f
77                                     "List font names available.")
78               (verbose ,(ly:command-line-verbose?) "value for the --verbose flag")
79               ))
80
81   (map
82    (lambda (x)
83      (ly:set-option (car x) (cdr x))) 
84    (eval-string (ly:command-line-options))))
85
86
87 ;; need to do this in the beginning. Other parts of the
88 ;; Scheme init depend on these options.
89 ;;
90 (define-scheme-options)
91
92
93
94 (debug-set! stack 0)
95
96 (if (defined? 'set-debug-cell-accesses!)
97     (set-debug-cell-accesses! #f))
98
99                                         ;(set-debug-cell-accesses! 1000)
100
101 (use-modules (ice-9 regex)
102              (ice-9 safe)
103              (ice-9 rdelim)
104              (ice-9 optargs)
105              (oop goops)
106              (srfi srfi-1)
107              (srfi srfi-13)
108              (srfi srfi-14)
109              (scm clip-region)
110              (scm memory-trace)
111              )
112
113 ;; my display
114 (define-public (myd k v) (display k) (display ": ") (display v) (display ", ")
115   v)
116
117 (define-public (print . args)
118   (apply format (cons (current-output-port) args)))
119
120
121 ;;; General settings
122 ;;; debugging evaluator is slower.  This should
123 ;;; have a more sensible default.
124
125 (if (or (ly:get-option 'verbose)
126         (ly:get-option 'trace-memory-frequencency))
127     (begin
128       (ly:set-option 'protected-scheme-parsing #f)
129       (debug-enable 'debug)
130       (debug-enable 'backtrace)
131       (read-enable 'positions)))
132
133 (define-public tex-backend?
134   (member (ly:output-backend) '("texstr" "tex")))
135
136 (define-public parser #f)
137
138 (define-public (lilypond-version)
139   (string-join
140    (map (lambda (x) (if (symbol? x)
141                         (symbol->string x)
142                         (number->string x)))
143         (ly:version))
144    "."))
145
146
147 ;; TeX C++ code actually hooks into TEX_STRING_HASHLIMIT 
148 (define-public TEX_STRING_HASHLIMIT 10000000)
149
150
151
152 ;; gettext wrapper for guile < 1.7.2
153 (if (defined? 'gettext)
154     (define-public _ gettext)
155     (define-public _ ly:gettext))
156
157 (define-public (ly:load x)
158   (let* ((file-name (%search-load-path x)))
159     (if (ly:get-option 'verbose)
160         (ly:progress "[~A" file-name))
161     (if (not file-name)
162         (ly:error (_ "cannot find: ~A") x))
163     (primitive-load file-name)
164     (if (ly:get-option 'verbose)
165         (ly:progress "]"))))
166
167 ;; Cygwin
168 ;; #(CYGWIN_NT-5.1 Hostname 1.5.12(0.116/4/2) 2004-11-10 08:34 i686)
169 ;;
170 ;; Debian
171 ;; #(Linux hostname 2.4.27-1-686 #1 Fri Sep 3 06:28:00 UTC 2004 i686)
172 ;;
173 ;; Mingw
174 ;; #(Windows XP HOSTNAME build 2600 5.01 Service Pack 1 i686)
175 ;;
176
177 ;; ugh, code dup.
178 (define-public PLATFORM
179   (string->symbol
180    (string-downcase
181     (car (string-tokenize (vector-ref (uname) 0) char-set:letter)))))
182
183 (define-public DOS
184   (let ((platform (string-tokenize
185                    (vector-ref (uname) 0) char-set:letter+digit)))
186     (if (null? (cdr platform)) #f
187         (member (string-downcase (cadr platform)) '("95" "98" "me")))))
188
189 (case PLATFORM
190   ((windows)
191    (define native-getcwd getcwd)
192    (define (slashify x)
193      (if (string-index x #\\)
194          x
195          (string-regexp-substitute
196           "//*" "/"
197           (string-regexp-substitute "\\\\" "/" x))))
198    ;; FIXME: this prints a warning.
199    (define-public (ly-getcwd)
200      (slashify (native-getcwd))))
201   (else (define-public ly-getcwd getcwd)))
202
203 (define-public (is-absolute? file-name)
204   (let ((file-name-length (string-length file-name)))
205     (if (= file-name-length 0)
206         #f
207         (or (eq? (string-ref file-name 0) #\/)
208             (and (eq? PLATFORM 'windows)
209                  (> file-name-length 2)
210                  (eq? (string-ref file-name 1) #\:)
211                  (eq? (string-ref file-name 2) #\/))))))
212
213 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
214
215 (define (type-check-list location signature arguments)
216   "Typecheck a list of arguments against a list of type
217 predicates. Print a message at LOCATION if any predicate failed."
218
219   (define (recursion-helper signature arguments count) 
220     (define (helper pred? arg count) 
221       (if (not (pred? arg))
222
223           (begin
224             (ly:input-message
225              location
226              (format
227               #f (_ "wrong type for argument ~a.  Expecting ~a, found ~s")
228               count (type-name pred?) arg))
229             #f)
230           #t))
231
232     (if (null? signature)
233         #t
234         (and (helper (car signature) (car arguments) count)
235              (recursion-helper (cdr signature) (cdr arguments) (1+ count)))))
236
237   (recursion-helper signature arguments 1))
238
239 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
240 ;;  output
241
242
243 ;;(define-public (output-framework) (write "hello\n"))
244
245 (define output-tex-module
246   (make-module 1021 (list (resolve-interface '(scm output-tex)))))
247 (define output-ps-module
248   (make-module 1021 (list (resolve-interface '(scm output-ps)))))
249
250 (define-public (ps-output-expression expr port)
251   (display (eval expr output-ps-module) port))
252
253 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
254 ;; Safe definitions utility
255 (define safe-objects (list))
256
257 (define-macro (define-safe-public arglist . body)
258   "Define a variable, export it, and mark it as safe, ie usable in LilyPond safe mode.
259 The syntax is the same as `define*-public'."
260   (define (get-symbol arg)
261     (if (pair? arg)
262         (get-symbol (car arg))
263         arg))
264   (let ((safe-symbol (get-symbol arglist)))
265     `(begin
266        (define*-public ,arglist
267          ,@body)
268        (set! safe-objects (cons (cons ',safe-symbol ,safe-symbol)
269                                 safe-objects))
270        ,safe-symbol)))
271
272 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
273 ;; init pitch system
274
275 (ly:set-default-scale (ly:make-scale #(0 1 2 5/2 7/2 9/2 11/2)))
276
277
278
279 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
280 ;; other files.
281
282
283 (define
284   init-scheme-files
285   '("lily-library.scm"
286             "file-cache.scm"
287             "define-event-classes.scm"
288             "define-music-types.scm"
289             "output-lib.scm"
290             "c++.scm"
291             "chord-ignatzek-names.scm"
292             "chord-entry.scm"
293             "chord-generic-names.scm"
294             "stencil.scm"
295             "markup.scm"
296             "music-functions.scm"
297             "part-combiner.scm"
298             "autochange.scm"
299             "define-music-properties.scm"
300             "auto-beam.scm"
301             "chord-name.scm"
302
303             "parser-ly-from-scheme.scm"
304             "ly-syntax-constructors.scm"
305             
306             "define-context-properties.scm"
307             "translation-functions.scm"
308             "script.scm"
309             "midi.scm"
310             "layout-beam.scm"
311             "parser-clef.scm"
312             "layout-slur.scm"
313             "font.scm"
314             "encoding.scm"
315             
316             "fret-diagrams.scm"
317             "define-markup-commands.scm"
318             "define-grob-properties.scm"
319             "define-grobs.scm"
320             "define-grob-interfaces.scm"
321             "define-stencil-commands.scm"
322             "titling.scm"
323             
324             "paper.scm"
325             "backend-library.scm"
326             "x11-color.scm"
327
328             ;; must be after everything has been defined
329             "safe-lily.scm"))
330
331
332
333
334 (for-each ly:load init-scheme-files)
335
336
337 (set! type-p-name-alist
338       `(
339         (,boolean-or-symbol? . "boolean or symbol")
340         (,boolean? . "boolean")
341         (,char? . "char")
342         (,grob-list? . "list of grobs")
343         (,hash-table? . "hash table")
344         (,input-port? . "input port")
345         (,integer? . "integer")
346         (,list? . "list")
347         (,ly:context? . "context")
348         (,ly:dimension? . "dimension, in staff space")
349         (,ly:dir? . "direction")
350         (,ly:duration? . "duration")
351         (,ly:grob? . "layout object")
352         (,ly:input-location? . "input location")
353         (,ly:moment? . "moment")
354         (,ly:music? . "music")
355         (,ly:pitch? . "pitch")
356         (,ly:translator? . "translator")
357         (,ly:font-metric? . "font metric")
358         (,ly:simple-closure? . "simple closure")
359         (,markup-list? . "list of markups")
360         (,markup? . "markup")
361         (,ly:music-list? . "list of music")
362         (,number-or-grob? . "number or grob")
363         (,number-or-string? . "number or string")
364         (,number-pair? . "pair of numbers")
365         (,number? . "number")
366         (,output-port? . "output port")   
367         (,pair? . "pair")
368         (,procedure? . "procedure")
369         (,rhythmic-location? . "rhythmic location")
370         (,scheme? . "any type")
371         (,string? . "string")
372         (,symbol? . "symbol")
373         (,vector? . "vector")))
374
375 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376 ;; timing
377
378 (define (profile-measurements)
379   (let* ((t (times))
380          (stats (gc-stats)))
381     
382     (list
383      (- (+ (tms:cutime t)
384            (tms:utime t))
385         (ly:assoc-get 'gc-time-taken stats))
386      
387      (ly:assoc-get 'total-cells-allocated  stats 0)
388      )))
389
390 (define (dump-profile base last this)
391   (let*
392       ((outname (format "~a.profile" (basename base ".ly")))
393        (diff (map (lambda (y) (apply - y)) (zip this last))))
394     
395     (ly:progress "\nWriting timing to ~a..." outname)
396     (format (open-file outname "w")
397             "time: ~a\ncells: ~a\n"
398             (car diff)
399             (cadr diff)
400             )))
401
402
403 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
404 ;; debug mem leaks
405
406 (define gc-dumping #f)
407 (define gc-protect-stat-count 0)
408
409 (define-public (dump-live-object-stats outfile)
410   (for-each
411    (lambda (x)
412      (format outfile "~a: ~a\n" (car x) (cdr x)))
413    (sort (gc-live-object-stats)
414          (lambda (x y)
415            (string<? (car x) (car y))))))
416
417 (define-public (dump-gc-protects)
418   (set! gc-protect-stat-count (1+ gc-protect-stat-count))
419   (let* ((protects (sort
420                     (hash-table->alist (ly:protects))
421                     (lambda (a b)
422                       (< (object-address (car a))
423                          (object-address (car b))))))
424
425          (out-file-name (string-append
426                          "gcstat-" (number->string gc-protect-stat-count)
427                          ".scm"))
428          (outfile    (open-file  out-file-name  "w")))
429
430     (set! gc-dumping #t)
431     (display (format "Dumping GC statistics ~a...\n" out-file-name))
432     (display
433      (map (lambda (y)
434             (let ((x (car y))
435                   (c (cdr y)))
436               (display 
437                (format "~a (~a) = ~a\n" (object-address x) c x)
438                outfile)))
439           (filter
440            (lambda (x)
441              (not (symbol? (car x))))
442            protects))
443      outfile)
444
445     (format outfile "\nprotected symbols: ~a\n"
446             (length (filter symbol?  (map car protects))))
447     
448              
449
450     ;; (display (ly:smob-protects))
451     (newline outfile)
452     (if (defined? 'gc-live-object-stats)
453         (let* ((stats #f))
454           (display "Live object statistics: GC'ing\n")
455           (ly:reset-all-fonts)
456           (gc)
457           (gc)
458           (display "Asserting dead objects\n")
459           (ly:set-option 'debug-gc-assert-parsed-dead #t)
460           (gc)
461           (ly:set-option 'debug-gc-assert-parsed-dead #f)
462
463           (set! stats (gc-live-object-stats))
464           (display "Dumping live object statistics.\n")
465           (dump-live-object-stats outfile)))
466
467     (newline outfile)
468     (let*
469         ((stats (gc-stats)))
470       
471       (for-each
472        (lambda (sym)
473          (display
474           (format "~a ~a ~a\n"
475                   gc-protect-stat-count
476                   sym
477                   (let ((sym-stat (assoc sym stats)))
478                     (if sym-stat 
479                         (cdr sym-stat)
480                         "?")))
481           outfile))
482        '(protected-objects bytes-malloced cell-heap-size
483                            
484                            )))
485
486     (set! gc-dumping #f)
487     (close-port outfile)
488     
489     ))
490
491
492 (define (check-memory)
493   "read /proc/self to check up on memory use." 
494   (define (gulp-file name)
495     (let* ((file (open-input-file name))
496            (text (read-delimited "" file)))
497       (close file)
498       text))
499   (let*
500       ((stat (gulp-file "/proc/self/status"))
501        (lines (string-split stat #\newline))
502        (interesting (filter identity
503                             (map
504                              (lambda (l)
505                                (string-match "^VmData:[ \t]*([0-9]*) kB" l))
506                              lines)))
507        (mem (string->number (match:substring (car interesting) 1)))
508        )
509
510     
511     (display (format  "VMDATA: ~a\n" mem))
512     (display (gc-stats))
513     (if (> mem 100000)
514         (begin
515           (dump-gc-protects)
516           (raise 1)))
517     
518     ))
519
520 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
521
522
523 (define (multi-fork count)
524   (define (helper count acc)
525     (if (> count 0)
526       (let*
527           ((pid  (primitive-fork)))
528         (if (= pid 0)
529             (1- count)
530             (helper (1- count) (cons pid acc))))
531       acc))
532   (helper count '()))
533
534
535 (define-public (lilypond-main files)
536   "Entry point for LilyPond."
537
538   (define (no-files-handler)
539     (ly:usage)
540     (exit 2))
541
542   (eval-string (ly:command-line-code))
543   
544   (if (ly:get-option 'gui)
545       (gui-main files))
546
547   (if (null? files)
548       (no-files-handler))
549
550   (if (ly:get-option 'read-file-list)
551       (set! files
552             (filter (lambda (s)
553                       (> (string-length s) 0))
554                     (apply append
555                            (map (lambda (f) (string-split (ly:gulp-file f) #\nl))
556                                 files)))
557             ))
558   
559   (if (and (number? (ly:get-option 'job-count))
560            (>= (length files) (ly:get-option 'job-count)))
561       
562       (let*
563           ((count (ly:get-option 'job-count))
564            (split-todo (split-list files count)) 
565            (joblist (multi-fork count))
566            (errors '()))
567
568         (if (not (string-or-symbol? (ly:get-option 'log-file)))
569             (ly:set-option 'log-file "lilypond-multi-run"))
570         
571         (if (number? joblist)
572             (begin
573               (ly:set-option 'log-file (format "~a-~a"
574                                                (ly:get-option 'log-file) joblist))
575               (set! files (vector-ref split-todo joblist)))
576
577             (begin
578               (ly:progress "\nForking into jobs:  ~a\n" joblist)
579               (for-each
580                (lambda (pid)
581                  (let* ((stat (cdr (waitpid pid))))
582                    
583                    (if (not (= stat 0))
584                        (set! errors (acons (list-element-index joblist pid) stat errors)))))
585                joblist)
586
587               (for-each
588                (lambda (x)
589                  (let* ((job (car x))
590                         (state (cdr x))
591                         (logfile  (format "~a-~a.log"
592                                           (ly:get-option 'log-file) job))
593                         (log (ly:gulp-file logfile))
594                         (len (string-length log))
595                         (tail (substring  log (max 0 (- len 1024)))))
596
597                    (if (status:term-sig state)
598                        (ly:message "\n\n~a\n"
599                                    (format (_ "job ~a terminated with signal: ~a")
600                                            job
601                                            (status:term-sig state)))
602                        (ly:message (_ "logfile ~a (exit ~a):\n~a") logfile (status:exit-val state) tail))))
603
604                errors)
605
606               (if (pair? errors)
607                   (ly:error "Children ~a exited with errors." (map car errors)))
608
609               ;; must overwrite individual entries
610               (if (ly:get-option 'dump-profile)
611                   (dump-profile "lily-run-total" '(0 0) (profile-measurements)))
612
613             (exit (if (null? errors) 0 1))))))
614               
615            
616   (if (string-or-symbol? (ly:get-option 'log-file))
617       (ly:stderr-redirect (format "~a.log" (ly:get-option 'log-file)) "w"))
618
619   
620   (let ((failed (lilypond-all files)))
621     (if (pair? failed)
622         (begin
623           (ly:error (_ "failed files: ~S") (string-join failed))
624           (exit 1))
625         (begin
626           ;; HACK: be sure to exit with single newline
627           (ly:message "")
628           (exit 0)))))
629
630 (define-public (lilypond-all files)
631   
632
633   (if (ly:get-option 'show-available-fonts)
634       (begin
635         (ly:font-config-display-fonts)
636         (exit 0)
637         ))
638   
639   (let* ((failed '())
640          (separate-logs (ly:get-option 'separate-log-files))
641          (do-measurements (ly:get-option 'dump-profile))
642          (handler (lambda (key failed-file)
643                     (set! failed (append (list failed-file) failed)))))
644
645     (gc)
646     (for-each
647      (lambda (x)
648        (let*
649            ((start-measurements (if do-measurements
650                                     (profile-measurements)
651                                     #f))
652             (base (basename x ".ly"))
653             (all-settings (ly:all-options)))
654
655          (if separate-logs
656              (ly:stderr-redirect (format "~a.log" base) "w"))
657          (if (ly:get-option 'trace-memory-frequency) 
658              (mtrace:start-trace  (ly:get-option 'trace-memory-frequency)))
659          
660          (lilypond-file handler x)
661          (if start-measurements
662              (dump-profile x start-measurements (profile-measurements)))
663
664          (if (ly:get-option 'trace-memory-frequency)
665              (begin
666                (mtrace:stop-trace)
667                (mtrace:dump-results base)))
668                  
669          (for-each
670           (lambda (s)
671             (ly:set-option (car s) (cdr s)))
672           all-settings)
673
674          (ly:clear-anonymous-modules)
675          (ly:set-option 'debug-gc-assert-parsed-dead #t)
676          (gc)
677          (ly:set-option 'debug-gc-assert-parsed-dead #f)
678
679          
680          (if (ly:get-option 'debug-gc)
681              (dump-gc-protects)
682              (if (= (random 40) 1)
683                  (ly:reset-all-fonts)))))
684
685      files)
686
687     ;; we want the failed-files notice in the aggregrate logfile.
688     (if (ly:get-option 'separate-logs)
689         (ly:stderr-redirect
690          (if (string-or-symbol? (ly:get-option 'log-file))
691              (format "~a.log" (ly:get-option 'log-file))
692              "/dev/tty") "a"))
693
694     (if (ly:get-option 'dump-profile)
695         (dump-profile "lily-run-total" '(0 0) (profile-measurements)))
696
697     failed))
698
699 (define (lilypond-file handler file-name)
700   (catch 'ly-file-failed
701          (lambda () (ly:parse-file file-name))
702          (lambda (x . args) (handler x file-name))))
703
704 (use-modules (scm editor))
705
706 (define-public (gui-main files)
707   (if (null? files)
708       (gui-no-files-handler))
709
710   (if (not (string? (ly:get-option 'log-file)))
711       (let* ((base (basename (car files) ".ly"))
712              (log-name (string-append base ".log")))
713         (if (not (ly:get-option 'gui))
714             (ly:message (_ "Redirecting output to ~a...") log-name))
715         (ly:stderr-redirect log-name "w")
716         (ly:message "# -*-compilation-*-"))
717     
718     (let ((failed (lilypond-all files)))
719       (if (pair? failed)
720           (begin
721             ;; ugh
722             (ly:stderr-redirect "foo" "r")
723             (system (get-editor-command log-name 0 0 0))
724             (ly:error (_ "failed files: ~S") (string-join failed))
725             ;; not reached?
726             (exit 1))
727           (exit 0)))))
728
729 (define (gui-no-files-handler)
730   (let* ((ly (string-append (ly:effective-prefix) "/ly/"))
731          ;; FIXME: soft-code, localize
732          (welcome-ly (string-append ly "Welcome_to_LilyPond.ly"))
733          (cmd (get-editor-command welcome-ly 0 0 0)))
734     (ly:message (_ "Invoking `~a'...") cmd)
735     (system cmd)
736     (exit 1)))