summaryrefslogtreecommitdiff
path: root/scheme/gambit/geiser/gambit.scm
diff options
context:
space:
mode:
authormathieu2em <math.per@hotmail.com>2019-08-22 13:50:04 -0400
committermathieu2em <math.per@hotmail.com>2019-08-22 22:51:15 -0400
commit6db4fb2cd0ca86f27b8e08e15e8493a2d08d48f2 (patch)
tree22167d48f234b7dcac7b05fa1f63267fc80331d4 /scheme/gambit/geiser/gambit.scm
parent73efe9010c753659efada9519a198be49442e03a (diff)
downloadgeiser-guile-6db4fb2cd0ca86f27b8e08e15e8493a2d08d48f2.tar.gz
geiser-guile-6db4fb2cd0ca86f27b8e08e15e8493a2d08d48f2.tar.bz2
better autocompletion with cleaner procedure
Diffstat (limited to 'scheme/gambit/geiser/gambit.scm')
-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<?))