(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 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
(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))
(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))))
-#!@GUILE@ \
+-#!@GUILE@ \
-e main -s
!#
;;;; lilypond-invoke-editor.scm -- Invoke an editor in file:line:column mode
;;;;
;;;; (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)
(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))
(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