This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: tab-completion implemented for Kawa
- From: Andrea Bernardini <andrebask at gmail dot com>
- To: kawa at sourceware dot org
- Date: Thu, 25 Feb 2016 23:33:13 +0000
- Subject: Re: tab-completion implemented for Kawa
- Authentication-results: sourceware.org; auth=none
- References: <56CE6324 dot 80502 at bothner dot com> <CAPFJfsva4VPt_RQ5NrNzY8n7oyZB0EGL7VuFAzsEcGS8ruDqbA at mail dot gmail dot com> <CAPFJfsvV+Lnrko6Bj008DLA7007of_1a-XOM0oAYH5JTXrFRpA at mail dot gmail dot com>
Hi Per,
This is a very nice feature!
BTW, something I miss in the Kawa REPL is some kind of history. I'm
used to the bash shell, where you can use the up arrow key to get the
previous executed commands. Currently pressing the arrow key in Kawa
inserts a weird sequence of characters. I know that other languages'
REPLs have the same problem (like Racket), however there are some that
support this feature (Python, Haskell). Do you think that could be
doable for Kawa?
All the best
Andrea
(Sorry for the double mail, Per)
On 25 February 2016 at 23:31, Andrea Bernardini <andrebask@gmail.com> wrote:
> Hi Per,
> This is a very nice feature!
>
> BTW, something I miss in the Kawa REPL is some kind of history. I'm used to
> the bash shell, where you can use the up arrow key to get the previous
> executed commands. Currently pressing the arrow key in Kawa inserts a weird
> sequence of characters. I know that other languages' REPLs have the same
> problem (like Racket), however there are some that support this feature
> (Python, Haskell). Do you think that could be doable for Kawa?
>
> All the best
>
> Andrea
>
> (Sorry for the double mail, Per)
>
>
> On 25 February 2016 at 23:27, Andrea Bernardini <andrebask@gmail.com> wrote:
>>
>> Hi Per,
>> This is a very nice feature!
>>
>> BTW, something I miss in the Kawa REPL is some kind of history. I'm used
>> to the bash shell, where you can use the up arrow key to get the previous
>> executed commands. Currently pressing the arrow key in Kawa inserts a weird
>> sequence of characters. I know that other languages' REPLs have the same
>> problem (like Racket), however there are some that support this feature
>> (Python, Haskell). Do you think that could be doable for Kawa?
>>
>> All the best
>>
>> Andrea
>>
>> On 25 February 2016 at 02:12, Per Bothner <per@bothner.com> wrote:
>>>
>>> I checked in an implementation of command-completion (tab-completion)
>>> for Kawa. This is context-senstive - for example the following works
>>> when using the JLine2 input-ediing library:
>>>
>>> #|Kawa:1|# ab<TAB>s
>>> abs absolute-path?
>>> #|Kawa:1|# abs<ENTER>
>>> #<procedure abs>
>>>
>>> Kawa wills in the 's' and gives you two options; <ENTER> choose "abs".
>>>
>>> What makes it interesting is that it is content-dependent,
>>> and includes bindings in the lexical scope:
>>>
>>> #|Kawa:2|# (let ((absol 12)) abso<TAB>l
>>> absol absolute-path?
>>>
>>> It works by running the compiler in tentative mode
>>> with "(let ((absol 12)) abso<COMPLETE>" as the input.
>>> Here <COMPLETE> is a special private-use Unicode character
>>> that tells the Kawa name-lookup framework to look for names
>>> starting with "abso".
>>>
>>> This "tentative mode" could also be useful for on-the-fly
>>> error checking, syntax coloring, use/definition cross-references.
>>> But that is for another day.
>>>
>>> Currently this only works with the JLine2 library.
>>> You have to:
>>> ./configure --with-jline2=/path/to/jline2.jar
>>>
>>> However, most of the logic is independent of JLine2, and
>>> is in the file gnu/expr/CommandCompleter.java. It should be
>>> doable (for-example) to have an Emacs frontend call the
>>> CommandCompleter#complete method.
>>> --
>>> --Per Bothner
>>> per@bothner.com http://per.bothner.com/
>>
>>
>