summaryrefslogtreecommitdiff
path: root/scheme/guile/geiser/introspection.scm
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2009-02-12 22:34:51 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2009-02-12 22:34:51 +0100
commitfa17e0cb3367e68e8db386497ddcfe3cfcf96416 (patch)
treebe439b2cfaeb69e8fa7a23ba4637f30135105f0a /scheme/guile/geiser/introspection.scm
parent0ead55f7052edb0f151e4e86c6feb30718d36bea (diff)
downloadgeiser-guile-fa17e0cb3367e68e8db386497ddcfe3cfcf96416.tar.gz
geiser-guile-fa17e0cb3367e68e8db386497ddcfe3cfcf96416.tar.bz2
M-. working for any symbol whose module can be located.
Diffstat (limited to 'scheme/guile/geiser/introspection.scm')
-rw-r--r--scheme/guile/geiser/introspection.scm29
1 files changed, 16 insertions, 13 deletions
diff --git a/scheme/guile/geiser/introspection.scm b/scheme/guile/geiser/introspection.scm
index 03d5796..136ada3 100644
--- a/scheme/guile/geiser/introspection.scm
+++ b/scheme/guile/geiser/introspection.scm
@@ -89,16 +89,7 @@
(let ((src (program-source prog 0)))
(and src (source:line src))))
-(define (module-filename name)
- (let* ((name (map symbol->string name))
- (reverse-name (reverse name))
- (leaf (car reverse-name))
- (dir-hint-module-name (reverse (cdr reverse-name)))
- (dir-hint (apply string-append
- (map (lambda (elt)
- (string-append elt "/"))
- dir-hint-module-name))))
- (%search-load-path (in-vicinity dir-hint leaf))))
+(define module-filename (@@ (ice-9 session) module-filename))
(define (program-file prog)
(let* ((mod (and prog (program-module prog)))
@@ -108,10 +99,22 @@
(define (program-location prog)
(make-location (program-file prog) (program-line prog)))
+(define (symbol-module sym)
+ (call/cc
+ (lambda (k)
+ (apropos-fold (lambda (module name var init)
+ (if (eq? name sym) (k (module-name module)) init))
+ #f
+ (symbol->string sym)
+ (apropos-fold-accessible (current-module))))))
+
+(define (make-location-from-module-name name)
+ (make-location (module-filename name) #f))
+
(define (symbol-location sym)
(let ((prog (resolve-symbol sym)))
- (if (program? prog)
- (program-location prog)
- '())))
+ (cond ((program? prog) (program-location prog))
+ ((symbol-module sym) => make-location-from-module-name)
+ (else '()))))
;;; introspection.scm ends here