diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2009-02-12 22:07:29 +0100 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2009-02-12 22:07:29 +0100 |
commit | f857023945f6eee65d9725684f22e022c3e6acc4 (patch) | |
tree | b5b735e248ed0ee18edc34e367be0d33ae4a10f6 /geiser/introspection.scm | |
parent | 3bb2a98e05b21cfd44aeb766eedb97e84408cc63 (diff) | |
download | geiser-guile-f857023945f6eee65d9725684f22e022c3e6acc4.tar.gz geiser-guile-f857023945f6eee65d9725684f22e022c3e6acc4.tar.bz2 |
Edit symbol at point for programs.
Diffstat (limited to 'geiser/introspection.scm')
-rw-r--r-- | geiser/introspection.scm | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/geiser/introspection.scm b/geiser/introspection.scm index 6ac3f69..03d5796 100644 --- a/geiser/introspection.scm +++ b/geiser/introspection.scm @@ -25,7 +25,7 @@ ;;; Code: (define-module (geiser introspection) - #:export (proc-args completions) + #:export (proc-args completions symbol-location) #:use-module (system vm program) #:use-module (ice-9 session) #:use-module (srfi srfi-1)) @@ -81,9 +81,37 @@ (apropos-internal (string-append "^" prefix))) string<?)) -(define (proc-location proc) - (let ((prog (resolve-symbol proc))) - (and prog - (program-source )))) +(define (make-location file line) + (list (cons 'file (if (string? file) file '())) + (cons 'line (if (number? line) (+ 1 line) '())))) + +(define (program-line prog) + (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 (program-file prog) + (let* ((mod (and prog (program-module prog))) + (name (and mod (module-name mod)))) + (and name (module-filename name)))) + +(define (program-location prog) + (make-location (program-file prog) (program-line prog))) + +(define (symbol-location sym) + (let ((prog (resolve-symbol sym))) + (if (program? prog) + (program-location prog) + '()))) ;;; introspection.scm ends here |