]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/lilypond-invoke-editor.scm
Fix #567.
[lilypond.git] / scripts / lilypond-invoke-editor.scm
old mode 100755 (executable)
new mode 100644 (file)
index 048ac3f..d847be2
@@ -4,7 +4,7 @@
 ;;;;
 ;;;; source file of the GNU LilyPond music typesetter
 ;;;;
-;;;; (c) 2005--2006 Jan Nieuwenhuizen <janneke@gnu.org>
+;;;; (c) 2005--2007 Jan Nieuwenhuizen <janneke@gnu.org>
 
 ;; gui debug helper
 ;; (define (exit x) (system "sleep 10"))
@@ -12,6 +12,7 @@
 (use-modules
  (ice-9 getopt-long)
  (ice-9 regex)
+ (srfi srfi-1)
  (srfi srfi-13)
  (srfi srfi-14))
 
 
 ;; argv0 relocation -- do in wrapper?
 
-
-(define LILYPONDPREFIX
+(define LILYPOND_DATADIR
   (let* ((prefix
-         (or (getenv "LILYPONDPREFIX")
+         (or (getenv "LILYPOND_DATADIR")
              (dirname  (dirname (car (command-line)))))))
     
 
@@ -124,6 +124,20 @@ Options:
        (format "~a ~a" (getenv "BROWSER") uri)
        (format #f "firefox -remote 'OpenURL(~a,new-tab)'" uri))))
 
+
+(define (strip-framework-path var)
+  (define pat "lilypond/usr")
+  (if (getenv var)
+      (let*
+         ((val (getenv var))
+          (paths (string-split val #\:))
+          (without (remove (lambda (s) (string-contains s pat))
+                           paths)))
+       
+       (if (not (= (length without)
+                   (length paths)))
+           (setenv var (string-join without ":"))))))
+
 (define (main args)
   (let ((files (parse-options args)))
     (if (running-from-gui?)
@@ -137,9 +151,11 @@ Options:
        (begin
          (show-help (current-error-port))
          (exit 2)))
-    (set! %load-path (cons LILYPONDPREFIX %load-path))
+    (set! %load-path (cons LILYPOND_DATADIR %load-path))
+
     (primitive-eval '(use-modules (scm editor)))
 
+    (strip-framework-path "LD_LIBRARY_PATH")
     (let* ((uri (car files)))
       (if (is-textedit-uri? uri)
          (run-editor uri)