[gambit-list] question on symbol completion

REPLeffect repleffect at gmail.com
Sat Oct 6 23:34:17 EDT 2012

On Sat, Oct 6, 2012 at 10:21 PM, REPLeffect <repleffect at gmail.com> wrote:
> What would it take to expose a procedure in the interpreter for
> completing symbols in the symbol table.  What I mean is, I'd like a
> scheme procedure I could call with a string representing either a full
> or a partial symbol, and the procedure would give me back a list of
> the possible completions for currently defined symbols.
> Essentially I want a procedure that does what the tab completion in
> the interpreter's REPL does.
> I'm using the partially-implemented swank backend that James Long was
> working on a while back, and I found these procedures that Marc posted
> to the list back in March of '09:
>  (define (symbol-table->list st)
>     (define (symbol-chain s syms)
>       (let loop ((s s) (syms syms))
>         (if (symbol? s)
>             (loop (##vector-ref s 2) (cons s syms))
>             syms)))
>     (let loop ((lst (vector->list st)) (syms '()))
>       (if (pair? lst)
>           (loop (cdr lst) (symbol-chain (car lst) syms))
>           (reverse syms))))
>  (define (interned-symbols)
>     (symbol-table->list (##symbol-table)))
>  (pp (length (interned-symbols)))
> (that was from this post:
> https://mercure.iro.umontreal.ca/pipermail/gambit-list/2009-March/003308.html
> )
> >From that I cobbled together a very inefficient hash-table-based tab
> completion (especially inefficient because of duplicating the entire
> symbol table in a hash table, one key per symbol).  I realize this is
> a complete kludge and wastes tremendous amounts of memory.  I'd like
> to do it right and just query the symbol table itself, since the data
> is obviously already there.
> I found the complete_word(), lineeditor_word_completion(), and
> visit_symbol() functions in os_tty.c, and I'm sure that the solution
> is to write a similar set of C functions to act as a scheme interface
> to do what I want.  However, I suspect I don't understand the code
> well enough at this point to do that correctly.
> I'd be willing to give it a shot if I thought I had a sufficient
> quantity of tips on how to get it done (I started to say 'pointers' on
> how to get it done, but I suspected that would only lead to a long
> string of programmer jokes that might derail this thread :-D ).
> It seems to me that this would be a good thing to have available for
> any application that might embed Gambit and/or communicate with a
> process running the Gambit interpreter.  I don't think the
> applicability would be in any way limited to slime/swank (though,
> admittedly, that is my primary motivation for having it).
> REPLeffect
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list

Sorry about that, no subject on the previous email.  I thought Gmail
warned you before sending without a subject, but it didn't warn me
this time.


More information about the Gambit-list mailing list