summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2009-02-12 22:07:29 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2009-02-12 22:07:29 +0100
commitf857023945f6eee65d9725684f22e022c3e6acc4 (patch)
treeb5b735e248ed0ee18edc34e367be0d33ae4a10f6
parent3bb2a98e05b21cfd44aeb766eedb97e84408cc63 (diff)
downloadgeiser-guile-f857023945f6eee65d9725684f22e022c3e6acc4.tar.gz
geiser-guile-f857023945f6eee65d9725684f22e022c3e6acc4.tar.bz2
Edit symbol at point for programs.
-rw-r--r--geiser/emacs.scm1
-rw-r--r--geiser/eval.scm4
-rw-r--r--geiser/introspection.scm38
3 files changed, 37 insertions, 6 deletions
diff --git a/geiser/emacs.scm b/geiser/emacs.scm
index 8f0fffd..a3212af 100644
--- a/geiser/emacs.scm
+++ b/geiser/emacs.scm
@@ -27,6 +27,7 @@
(define-module (geiser emacs)
#:re-export (ge:proc-args
ge:completions
+ ge:symbol-location
ge:compile-file
ge:load-file)
#:use-module ((geiser introspection)
diff --git a/geiser/eval.scm b/geiser/eval.scm
index 1400566..8a7f48f 100644
--- a/geiser/eval.scm
+++ b/geiser/eval.scm
@@ -70,7 +70,9 @@ SUBR, MSG and REST."
(current (getcwd)))
(dynamic-wind
(lambda () (chdir dest))
- (lambda () (compile-file path))
+ (lambda ()
+ (and (compile-file path)
+ (load-compiled (string-append dest "/" (compiled-file-name path)))))
(lambda () (chdir current)))))
(define (load-file path)
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