]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/editor.scm
* scm/editor.scm (slashify): New function.
[lilypond.git] / scm / editor.scm
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))