]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/lily.scm
remove latin1.enc rules.
[lilypond.git] / scm / lily.scm
index 958f10087eac9c3535ba2712f3dc5c17fa5e34ce..6a6c8c64745673baaf50f17d75f535d0f0da7324 100644 (file)
@@ -2,7 +2,7 @@
 ;;;;
 ;;;;  source file of the GNU LilyPond music typesetter
 ;;;; 
-;;;; (c)  1998--2004 Jan Nieuwenhuizen <janneke@gnu.org>
+;;;; (c) 1998--2005 Jan Nieuwenhuizen <janneke@gnu.org>
 ;;;; Han-Wen Nienhuys <hanwen@cs.uu.nl>
 
 
@@ -13,6 +13,7 @@
 
 (use-modules (ice-9 regex)
             (ice-9 safe)
+             (ice-9 optargs)
             (oop goops)
             (srfi srfi-1)  ; lists
             (srfi srfi-13)) ; strings
@@ -46,6 +47,9 @@
 
 (define-public point-and-click #f)
 
+(define-public tex-backend?
+  (member (ly:output-backend) '("texstr" "tex")))
+
 (define-public parser #f)
 
 (define-public (lilypond-version)
@@ -85,10 +89,11 @@ predicates. Print a message at LOCATION if any predicate failed."
       (if (not (pred? arg))
 
          (begin
-           (ly:input-message location
-                             (format #f
-                                     (_ "wrong type for argument ~a. Expecting ~a, found ~s")
-                                     count (type-name pred?) arg))
+           (ly:input-message
+            location
+            (format
+             #f (_ "wrong type for argument ~a.  Expecting ~a, found ~s")
+             count (type-name pred?) arg))
            #f)
          #t))
 
@@ -134,8 +139,10 @@ predicates. Print a message at LOCATION if any predicate failed."
     repeat-slash
     round-filled-box
     text
+    url-link
     white-dot
     white-text
+    embedded-ps
     zigzag-line))
 
 ;; TODO:
@@ -151,12 +158,33 @@ predicates. Print a message at LOCATION if any predicate failed."
     placebox
     unknown))
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Safe definitions utility
+(define safe-objects (list))
+
+(define-macro (define-safe-public arglist . body)
+  "Define a variable, export it, and mark it as safe, ie usable in LilyPond safe mode.
+The syntax is the same as `define*-public'."
+  (define (get-symbol arg)
+    (if (pair? arg)
+        (get-symbol (car arg))
+        arg))
+  (let ((safe-symbol (get-symbol arglist)))
+    `(begin
+       (define*-public ,arglist
+         ,@body)
+       (set! safe-objects (cons (cons ',safe-symbol ,safe-symbol)
+                                safe-objects))
+       ,safe-symbol)))
+
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; other files.
 
 (for-each ly:load
          ;; load-from-path
          '("lily-library.scm"
+           "file-cache.scm"
            "define-music-types.scm"
            "output-lib.scm"
            "c++.scm"
@@ -193,7 +221,7 @@ predicates. Print a message at LOCATION if any predicate failed."
            "titling.scm"
            
            "paper.scm"
-
+           "backend-library.scm"
                                        ; last:
            "safe-lily.scm"))
 
@@ -267,58 +295,7 @@ predicates. Print a message at LOCATION if any predicate failed."
      outfile)))
 
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
-
-(define-public (ly:system command)
-  (let* ((status 0)
-
-        (silenced
-         (string-append command (if (ly:get-option 'verbose)
-                                    ""
-                                    " > /dev/null 2>&1 "))))
-    
-    (if (ly:get-option 'verbose)
-       (format  (current-error-port) (_ "Invoking `~a'...\n") command))
-    
-    (set! status (system silenced))
-    (if (> status 0)
-       (begin
-         (format (current-error-port)
-                 (_ "Error invoking `~a'. Return value ~a") silenced status)
-         (newline (current-error-port))))))
-
-(define-public (sanitize-command-option str)
-  (string-append
-   "\""
-   (regexp-substitute/global #f "[^- 0-9,.a-zA-Z'\"\\]" str 'pre 'post)
-   "\""))
-
-(define-public (postscript->pdf papersizename name)
-  (let* ((cmd (string-append "ps2pdf "
-                            (string-append
-                             " -sPAPERSIZE="
-                             (sanitize-command-option papersizename)
-                             " "
-                             name)))
-        (pdf-name (string-append (basename name ".ps") ".pdf" )))
-
-    (if (access? pdf-name W_OK)
-       (delete-file pdf-name))
-
-    (format (current-error-port) (_ "Converting to `~a'...") pdf-name)
-    (ly:system cmd)))
-
-(define-public (postscript->png resolution name)
-  (let ((cmd (string-append
-             "ps2png --resolution="
-             (if (number? resolution)
-                 (number->string resolution)
-                 "90 ")
-             (if (ly:get-option 'verbose)
-                 "--verbose "
-                 " ")
-             name)))
-    (ly:system cmd)))
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (define-public (lilypond-main files)
   "Entry point for LilyPond."