From 5dc8efd319f305e4322269ebc9d7836cb1c23764 Mon Sep 17 00:00:00 2001 From: dieggsy Date: Thu, 20 Jun 2019 03:27:46 -0400 Subject: More accurate Chicken completions, inspired by breadline - Fixes #276 --- scheme/chicken/geiser/chicken5.scm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/scheme/chicken/geiser/chicken5.scm b/scheme/chicken/geiser/chicken5.scm index 5409058..6b449df 100644 --- a/scheme/chicken/geiser/chicken5.scm +++ b/scheme/chicken/geiser/chicken5.scm @@ -276,10 +276,21 @@ ;; Completions, Autodoc and Signature ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + (define (current-environment-completions prefix) + (let ((size (string-length prefix))) + (filter + (lambda (candidate) (substring=? prefix candidate 0 0 size)) + (map (o symbol->string car) (##sys#current-environment))))) + + (define (apropos-completions prefix) + (let ((candidates (apropos-list `(: bos ,prefix) #:macros? #t))) + (remove + (lambda (candidate) (substring-index "#" candidate)) + (map symbol->string candidates)))) + (define (geiser-completions prefix . rest) - (let ((prefix (->string prefix))) - (filter (cut string-has-prefix? <> prefix) - (map ->string (map car (symbol-information-list prefix)))))) + (append (apropos-completions prefix) + (current-environment-completions prefix))) (define (geiser-module-completions prefix . rest) '()) -- cgit v1.2.3