This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: tab-completion implemented for Kawa


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/
>>
>>
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]