diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2009-02-12 22:34:51 +0100 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2009-02-12 22:34:51 +0100 |
commit | fe4864246c62fbdab1eb5606ba27aaeb3a9ab7cc (patch) | |
tree | 66052fb1fcfa59cefee47092e4d670a8d45b0bba /geiser/introspection.scm | |
parent | f857023945f6eee65d9725684f22e022c3e6acc4 (diff) | |
download | geiser-guile-fe4864246c62fbdab1eb5606ba27aaeb3a9ab7cc.tar.gz geiser-guile-fe4864246c62fbdab1eb5606ba27aaeb3a9ab7cc.tar.bz2 |
M-. working for any symbol whose module can be located.
Diffstat (limited to 'geiser/introspection.scm')
-rw-r--r-- | geiser/introspection.scm | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/geiser/introspection.scm b/geiser/introspection.scm index 03d5796..136ada3 100644 --- a/geiser/introspection.scm +++ b/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 |