summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scheme/gambit/geiser/gambit.scm39
1 files changed, 32 insertions, 7 deletions
diff --git a/scheme/gambit/geiser/gambit.scm b/scheme/gambit/geiser/gambit.scm
index d8cae00..b13d5e3 100644
--- a/scheme/gambit/geiser/gambit.scm
+++ b/scheme/gambit/geiser/gambit.scm
@@ -117,20 +117,45 @@
(list (##procedure-search method-name)))))
(define (geiser:module-completions prefix . rest)
+
(define (environment-symbols)
- (map car ##gambit-procedures))
- (##sort-list (filter (lambda (el)
- (##string-prefix? prefix el))
- (map symbol->string (environment-symbols)))
- string-ci<?))
+ (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 (##string-prefix? prefix sym)
+ (cons (symbol->string sym) symbols-list)
+ symbols-list))
+ (vect sym))
+ (let ((sym2 (##vector-ref vect 2)))
+ (if (symbol? sym2)
+ (if (##string-prefix? prefix sym2)
+ (loop2 (cons (symbol->string sym2) sym-list) sym2)
+ (loop2 sym-list sym2))
+ sym-list)))
+ symbols-list)))
+ symbols-list))))
+
+ (##sort-list (environment-symbols) string-ci<?))
+
+ ;; (##sort-list (filter (lambda (el)
+ ;; (##string-prefix? prefix el)) ;; eviter le map -> symbol->string externe
+ ;; (map symbol->string (environment-symbols)))
+ ;; string-ci<?))
(define (geiser:completions prefix . rest)
rest)
;; string-prefix function
(define (##string-prefix? pref str)
- (let ((str-len (string-length str))
- (pref-len (string-length pref)))
+ (let* ((str (if (string? str) str (symbol->string str)))
+ (str-len (string-length str))
+ (pref (if (string? pref) pref (symbol->string pref)))
+ (pref-len (string-length pref)))
(and (string? pref)
(string? str)
(<= pref-len str-len)