]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/lilypond-invoke-editor.scm
Merge branch 'master' of ssh+git://jneem@git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / scripts / lilypond-invoke-editor.scm
index 9fe02c467f5beef121b207a2607e2ad63d6fbd05..275aa901d88304e05d08f1cd1cbaffddbdf1c8f9 100755 (executable)
@@ -1,11 +1,10 @@
-#!@GUILE@ \
--e main -s
+#!@GUILE@ -s
 !#
 ;;;; lilypond-invoke-editor.scm -- Invoke an editor in file:line:column mode
 ;;;;
 ;;;; source file of the GNU LilyPond music typesetter
 ;;;;
-;;;; (c)  2005 Jan Nieuwenhuizen <janneke@gnu.org>
+;;;; (c) 2005--2006 Jan Nieuwenhuizen <janneke@gnu.org>
 
 ;; gui debug helper
 ;; (define (exit x) (system "sleep 10"))
@@ -13,6 +12,7 @@
 (use-modules
  (ice-9 getopt-long)
  (ice-9 regex)
+ (srfi srfi-1)
  (srfi srfi-13)
  (srfi srfi-14))
 
@@ -24,7 +24,6 @@
 
 ;; argv0 relocation -- do in wrapper?
 
-
 (define LILYPONDPREFIX
   (let* ((prefix
          (or (getenv "LILYPONDPREFIX")
@@ -120,9 +119,23 @@ Options:
          (exit 1)))))
 
 (define (run-browser uri)
+  (system
+   (if (getenv "BROWSER")
+       (format "~a ~a" (getenv "BROWSER") uri)
+       (format #f "firefox -remote 'OpenURL(~a,new-tab)'" uri))))
+
 
-  ;; TODO: make educated guess which browser to run.
-  (system (format #f "firefox -remote 'OpenURL(~a,new-tab)'" uri)))
+(define (strip-framework-path var)
+  (define pat "lilypond/usr")
+  (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)))
@@ -138,10 +151,13 @@ Options:
          (show-help (current-error-port))
          (exit 2)))
     (set! %load-path (cons LILYPONDPREFIX %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)
          (run-browser uri)))))
 
+(main (command-line))