(format port "~a (GNU LilyPond) ~a \n" PROGRAM-NAME TOPLEVEL-VERSION))
(define (show-help port)
- (format port (_ "Usage: lilypond-invoke-editor [textedit://]FILE:LINE:COLUMN
+ (format port (_ "Usage: lilypond-invoke-editor [textedit://]FILE:LINE:CHAR:COLUMN
-Visit a file and position the cursor
+Visit a file and position the cursor.
Options:
- -h,--help show this help
- -v,--version show version
+ -h, --help show this help
+ -v, --version show version
")))
(define (parse-options args)
(show-version (current-error-port))
files))
-;;(define (re-sub re sub string)
-;; (let ((sub-string (if (string? sub) sub (sub re))))
-;; (regexp-substitute/global #f re string 'pre sub-string 'post)))
(define (re-sub re sub string)
(regexp-substitute/global #f re string 'pre sub 'post))
(define (dissect-uri uri)
(let* ((ri "textedit://")
- (file-name:line:column (re-sub ri "" uri))
- (match (string-match "(.*):([^:]+):(.*)$" file-name:line:column)))
+ (file-name:line:char:column (re-sub ri "" uri))
+ (match (string-match "(.*):([^:]+):([^:]+):(.*)$" file-name:line:char:column)))
(if match
(list (unquote-uri (match:substring match 1))
(match:substring match 2)
- (match:substring match 3))
+ (match:substring match 3)
+ (match:substring match 4))
(begin
;; FIXME: why be so strict wrt :LINE:COLUMN,
;; esp. considering omitting textedit:// is explicitly
;; allowed.
(format (current-error-port) (_ "invalid URI: ~a") uri)
(newline (current-error-port))
- (format (current-error-port) (_ "expect: ~aFILE:LINE:COLUMN") ri)
+ (format (current-error-port) (_ "expect: ~aFILE:LINE:CHAR:COLUMN") ri)
(newline (current-error-port))
(exit 1)))))
(if (not (= (length files) 1))
(begin
(show-help (current-error-port))
- (exit 1)))
+ (exit 2)))
(set! %load-path (cons LILYPONDPREFIX %load-path))
(primitive-eval '(use-modules (scm editor)))
(let* ((uri (car files))