]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/editor.scm (slashify): New function.
authorJan Nieuwenhuizen <janneke@gnu.org>
Sun, 15 May 2005 11:45:13 +0000 (11:45 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sun, 15 May 2005 11:45:13 +0000 (11:45 +0000)
(get-editor-command): Use it.
(get-command-template): Do not alter editor command if
environment value includes `%(file)s' magic.

* scripts/lilypond-invoke-editor.scm (unquote-uri): New function.
(dissect-uri): Use it.
(unquote-uri): Bugfix.

ChangeLog
scm/editor.scm
scm/lily.scm
scripts/lilypond-invoke-editor.scm

index 864de9931a9d0f09054b2178fa12c9fb4eb624e6..a411ffe934dd4b269b69dad4d8c5afefa3c1fc28 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2005-05-15  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+       * scm/editor.scm (slashify): New function.
+       (get-editor-command): Use it.
+       (get-command-template): Do not alter editor command if
+       environment value includes `%(file)s' magic.
+
+       * scripts/lilypond-invoke-editor.scm (unquote-uri): New function.
+       (dissect-uri): Use it.
+       (unquote-uri): Bugfix.
+
 2005-05-15  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
        * Documentation/topdocs/README.texi (Top): remove note about
index aeea02b615eb95cb432133ed256c6133bef8894a..b02d3917f47ed2f475c7b17ee8827d87c25ed59d 100644 (file)
       (getenv "EDITOR")
       "emacs"))
 
-(define (re-sub re sub string)
-  (regexp-substitute/global #f re string 'pre sub 'post))
-
-(define-public (get-editor-command file-name line column)
-  (define (get-command-template alist editor)
+(define (get-command-template alist editor)
+  (define (get-command-template-helper)
     (if (null? alist)
        (if (string-match "%\\(file\\)s" editor)
            editor
        (if (string-match (caar alist) editor)
            (cdar alist)
            (get-command-template (cdr alist) editor))))
+  (if (string-match "%\\(file\\)s" editor)
+      editor
+      (get-command-template-helper)))
 
+(define (re-sub re sub string)
+  (regexp-substitute/global #f re string 'pre sub 'post))
+
+(define (slashify x)
+ (if (string-index x #\/)
+     x
+     (re-sub "\\\\" "/" x)))
+
+(define-public (get-editor-command file-name line column)
   (let* ((editor (get-editor))
         (template (get-command-template editor-command-template-alist editor))
         (command
          (re-sub "%\\(file\\)s" (format #f "~S" file-name)
                  (re-sub "%\\(line\\)s" (format #f "~a" line)
                          (re-sub "%\\(column\\)s" (format #f "~a" column)
-                                 template)))))
+                                 (slashify template))))))
     command))
index 565a5e3c696526e188d6c42f0e1a7b7e70c46f1a..23d2152f077b7b00cd77f6de70a81d872cb3f390 100644 (file)
@@ -97,7 +97,7 @@
    (define (slashify x)
      (if (string-index x #\/)
         x
-        (string-regexp-substitute "\\" "/" x)))
+        (string-regexp-substitute "\\\\" "/" x)))
    ;; FIXME: this prints a warning.
   (define-public (ly-getcwd)
      (slashify (native-getcwd))))
index 26e7e364a4bf9733b3394c18bc78919f14b10ac2..a21630053b076546a914ffae8636539cd1e451b6 100755 (executable)
@@ -1,4 +1,4 @@
-#!@GUILE@ \
+-#!@GUILE@ \
 -e main -s
 !#
 ;;;; lilypond-invoke-editor.scm -- Invoke an editor in file:line:column mode
@@ -7,6 +7,9 @@
 ;;;;
 ;;;; (c)  2005 Jan Nieuwenhuizen <janneke@gnu.org>
 
+;; gui debug helper
+;; (define (exit x) (system "sleep 10"))
+
 (use-modules
  (ice-9 getopt-long)
  (ice-9 regex)
@@ -14,7 +17,7 @@
  (srfi srfi-14))
 
 (define PROGRAM-NAME "lilypond-invoke-editor")
-(define TOPLEVEL-VERSION "@TOPLEVEL_VERSION@")
+(define TOPLEVEL-VERSION "2.5.25")
 (define DATADIR "@DATADIR@")
 (define COMPILE-TIME-PREFIX
   (format #f "~a/lilypond/~a" DATADIR TOPLEVEL-VERSION))
@@ -53,15 +56,26 @@ Options:
     (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))
 
+;; FIXME: I'm going slowly but certainly mad, I really cannot find the
+;; scm library function for this.
+(define (unquote-uri uri)
+  (re-sub "%([A-Fa-f0-9]{2})"
+         (lambda (m)
+           (string (integer->char (string->number (match:substring m 1) 16))))
+         uri))
+  
 (define (dissect-uri uri)
   (let* ((ri "textedit://")
         (file-name:line:column (re-sub ri "" uri))
         (match (string-match "(.*):([^:]+):(.*)$" file-name:line:column)))
     (if match
-       (list (match:substring match 1)
+       (list (unquote-uri (match:substring match 1))
              (match:substring match 2)
              (match:substring match 3))
        (begin