From 10fc0f3411cf838ee67e01df75fe8d84de367319 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sun, 3 May 2009 13:44:22 +0200 Subject: Better edit location heuristics. --- scheme/plt/geiser/locations.ss | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'scheme') 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 -- cgit v1.2.3