diff options
author | mathieu2em <math.per@hotmail.com> | 2019-07-23 14:33:37 -0400 |
---|---|---|
committer | mathieu2em <math.per@hotmail.com> | 2019-08-20 15:31:38 -0400 |
commit | efea09184eed27ca9a86e1a96a39203326633616 (patch) | |
tree | c2812fee509a4953eb6cc64994f562bfac1849ef /scheme/gambit | |
parent | e4370c6dfd8ef616defddb115402b385e2ec567d (diff) | |
download | geiser-guile-efea09184eed27ca9a86e1a96a39203326633616.tar.gz geiser-guile-efea09184eed27ca9a86e1a96a39203326633616.tar.bz2 |
completion now working and taking account of user's defined functions
Diffstat (limited to 'scheme/gambit')
-rw-r--r-- | scheme/gambit/geiser/gambit.scm | 39 |
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) |