summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scheme/gambit/geiser/gambit.scm40
1 files changed, 18 insertions, 22 deletions
diff --git a/scheme/gambit/geiser/gambit.scm b/scheme/gambit/geiser/gambit.scm
index 74682f5..c3cedc4 100644
--- a/scheme/gambit/geiser/gambit.scm
+++ b/scheme/gambit/geiser/gambit.scm
@@ -101,29 +101,25 @@
(define (geiser:module-completions prefix . rest)
+ (define (interesting? sym)
+ (and (string-prefix? prefix (symbol->string sym))
+ (procedure? (##global-var-ref (##make-global-var sym)))))
+
(define (environment-symbols)
- (let* ((sym-tab (##symbol-table))
- (sym-len (vector-length sym-tab)))
- (let loop ((i 1)
- (symbols-list '()))
- (if (< i sym-len)
- (let ((sym (vector-ref sym-tab i)))
- (loop (+ i 1)
- (if (symbol? sym)
- (let loop2 ((sym-list (if (and (string-prefix? prefix sym)
- (procedure? (##global-var-ref (##make-global-var sym))))
- (cons (symbol->string sym) symbols-list)
- symbols-list))
- (vect sym))
- (let ((sym2 (##vector-ref vect 2)))
- (if (symbol? sym2)
- (if (and (string-prefix? prefix sym2)
- (procedure? (##global-var-ref (##make-global-var sym))))
- (loop2 (cons (symbol->string sym2) sym-list) sym2)
- (loop2 sym-list sym2))
- sym-list)))
- symbols-list)))
- symbols-list))))
+ (let ((symtab (##symbol-table)))
+ (let loop1 ((i (- (vector-length symtab) 1))
+ (result '()))
+ (if (> i 0)
+ (let loop2 ((sym (vector-ref symtab i))
+ (result result))
+ (if (symbol? sym)
+ (loop2 (##vector-ref sym 2)
+ (if (interesting? sym)
+ (cons (symbol->string sym) result)
+ result))
+ (loop1 (- i 1)
+ result)))
+ result))))
(sort-list (environment-symbols) string-ci<?))