summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--elisp/geiser-edit.el20
-rw-r--r--scheme/plt/geiser/locations.ss27
2 files changed, 35 insertions, 12 deletions
diff --git a/elisp/geiser-edit.el b/elisp/geiser-edit.el
index 9471981..c02e7bb 100644
--- a/elisp/geiser-edit.el
+++ b/elisp/geiser-edit.el
@@ -54,6 +54,9 @@
((eq method 'frame) (find-file-other-frame file))
(t (find-file file))))
+(defsubst geiser-edit--location-name (loc)
+ (cdr (assoc 'name loc)))
+
(defsubst geiser-edit--location-file (loc)
(cdr (assoc 'file loc)))
@@ -65,7 +68,6 @@
"defmacro"
"define-macro"
"define-syntax"
- "define-syntaxes"
"-define-syntax"
"-define"
"define*"
@@ -73,8 +75,18 @@
"define-class"
"define-struct")))
+(defconst geiser-edit--def-re*
+ (regexp-opt '("define-syntaxes" "define-values")))
+
(defsubst geiser-edit--def-re (thing)
- (format "(%s +(?%s\\_>" geiser-edit--def-re (regexp-quote (format "%s" thing))))
+ (format "(%s +(?%s\\_>"
+ geiser-edit--def-re
+ (regexp-quote (format "%s" thing))))
+
+(defsubst geiser-edit--def-re* (thing)
+ (format "(%s +([^)]*?\\_<%s\\_>"
+ geiser-edit--def-re*
+ (regexp-quote (format "%s" thing))))
(defsubst geiser-edit--symbol-re (thing)
(format "\\_<%s\\_>" (regexp-quote (format "%s" thing))))
@@ -84,11 +96,13 @@
(goto-line line)
(goto-char (point-min))
(when (or (re-search-forward (geiser-edit--def-re symbol) nil t)
+ (re-search-forward (geiser-edit--def-re* symbol) nil t)
(re-search-forward (geiser-edit--symbol-re symbol) nil t))
(goto-char (match-beginning 0)))))
(defun geiser-edit--try-edit-location (symbol loc &optional method)
- (let ((file (geiser-edit--location-file loc))
+ (let ((symbol (or (geiser-edit--location-name loc) symbol))
+ (file (geiser-edit--location-file loc))
(line (geiser-edit--location-line loc)))
(unless file (error "Couldn't find edit location for '%s'" symbol))
(unless (file-readable-p file) (error "Couldn't open '%s' for read" file))
diff --git a/scheme/plt/geiser/locations.ss b/scheme/plt/geiser/locations.ss
index 1b13e8f..b738a48 100644
--- a/scheme/plt/geiser/locations.ss
+++ b/scheme/plt/geiser/locations.ss
@@ -27,22 +27,31 @@
#lang scheme
(provide symbol-location
- symbol-module-path-name
- symbol->module-name)
+ symbol-module-name
+ symbol-module-path-name)
(require geiser/utils)
-(define (symbol-module-path-name sym)
- (let ([binding (identifier-binding sym)])
- (and (list? binding)
+(define (%symbol-location sym)
+ (let* ((id (namespace-symbol->identifier sym))
+ (binding (and id (identifier-binding id))))
+ (if (list? binding)
+ (cons
+ (cadr binding)
(resolved-module-path-name
- (module-path-index-resolve (car binding))))))
+ (module-path-index-resolve (car binding))))
+ (cons sym #f))))
(define (symbol-location sym)
- (let ((file (symbol-module-path-name (namespace-symbol->identifier sym))))
- (list (cons 'file (if (path? file) (path->string file) '())))))
+ (let* ((loc (%symbol-location sym))
+ (name (car loc))
+ (path (cdr loc)))
+ (list (cons 'name name)
+ (cons 'file (if (path? path) (path->string path) '())))))
-(define symbol->module-name
+(define symbol-module-path-name (compose cdr %symbol-location))
+
+(define symbol-module-name
(compose module-path-name->name symbol-module-path-name))
;;; locations.ss ends here