-#!@GUILE@ \
--e main -s
+#!@GUILE@ -s
!#
;;;; lilypond-invoke-editor.scm -- Invoke an editor in file:line:column mode
+
+;;;; Copyright (C) 2005--2012 Jan Nieuwenhuizen <janneke@gnu.org>
+
+;;;; This file is part of LilyPond, the GNU music typesetter.
;;;;
-;;;; source file of the GNU LilyPond music typesetter
+;;;; LilyPond is free software: you can redistribute it and/or modify
+;;;; it under the terms of the GNU General Public License as published by
+;;;; the Free Software Foundation, either version 3 of the License, or
+;;;; (at your option) any later version.
;;;;
-;;;; (c) 2005 Jan Nieuwenhuizen <janneke@gnu.org>
+;;;; LilyPond is distributed in the hope that it will be useful,
+;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;;; GNU General Public License for more details.
+;;;;
+;;;; You should have received a copy of the GNU General Public License
+;;;; along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
;; gui debug helper
;; (define (exit x) (system "sleep 10"))
(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)))))))
(format #f "~a/share/lilypond/~a"
prefix TOPLEVEL-VERSION))))
-
-
-;; gettext wrapper for guile < 1.7.2
-(if (defined? 'gettext)
- (define-public _ gettext)
- (define-public (_ x) x))
+(define-public _ gettext)
(define (show-version port)
- (format port "~a (GNU LilyPond) ~a \n" PROGRAM-NAME TOPLEVEL-VERSION))
+ (format port "~a (GNU LilyPond) ~a\n" PROGRAM-NAME TOPLEVEL-VERSION))
(define (show-help port)
(format port (_ "Usage: lilypond-invoke-editor [textedit://]FILE:LINE:CHAR:COLUMN
(exit 1)))))
(define (run-browser uri)
-
- ;; TODO: make educated guess which browser to run.
- (system (format #f "firefox -remote 'OpenURL(~a,new-tab)'" uri)))
+ (system
+ (if (getenv "BROWSER")
+ (format #f "~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)))
(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)
(run-browser uri)))))
+(main (command-line))