Hi REPLeffect,<div><br></div><div>This is interesting stuff, please let the ml know what you get to.</div><div><br></div><div>Now, this is already under the hood in Gambit so one way of getting this would be just to dig it out.</div>

<div><br></div><div>Also, I would guess that the way it's implemented there is CPU-inexpensive, so it'd be a good place to learn from. Just hunt around in _repl.scm or alike for any handling of the tab character?</div>

<div><br></div><div>Mikael<br><br><div class="gmail_quote">2012/10/7 REPLeffect <span dir="ltr"><<a href="mailto:repleffect@gmail.com" target="_blank">repleffect@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

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