* tab-completion implemented for Kawa @ 2016-02-25 2:13 Per Bothner [not found] ` <CAPFJfsva4VPt_RQ5NrNzY8n7oyZB0EGL7VuFAzsEcGS8ruDqbA@mail.gmail.com> 0 siblings, 1 reply; 4+ messages in thread From: Per Bothner @ 2016-02-25 2:13 UTC (permalink / raw) To: Kawa mailing list 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/ ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <CAPFJfsva4VPt_RQ5NrNzY8n7oyZB0EGL7VuFAzsEcGS8ruDqbA@mail.gmail.com>]
[parent not found: <CAPFJfsvV+Lnrko6Bj008DLA7007of_1a-XOM0oAYH5JTXrFRpA@mail.gmail.com>]
* Re: tab-completion implemented for Kawa [not found] ` <CAPFJfsvV+Lnrko6Bj008DLA7007of_1a-XOM0oAYH5JTXrFRpA@mail.gmail.com> @ 2016-02-25 23:33 ` Andrea Bernardini 2016-02-25 23:51 ` Per Bothner 0 siblings, 1 reply; 4+ messages in thread From: Andrea Bernardini @ 2016-02-25 23:33 UTC (permalink / raw) To: 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/ >> >> > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: tab-completion implemented for Kawa 2016-02-25 23:33 ` Andrea Bernardini @ 2016-02-25 23:51 ` Per Bothner 2016-02-26 0:48 ` Andrea Bernardini 0 siblings, 1 reply; 4+ messages in thread From: Per Bothner @ 2016-02-25 23:51 UTC (permalink / raw) To: Andrea Bernardini, kawa On 02/25/2016 03:33 PM, Andrea Bernardini wrote: > Hi Per, > This is a very nice feature! Thanks! > > 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. That what the arrow keys are supposed to send. However, Java doesn't have a portable pure-Java mechanism to interpret those key sequences. > 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? That's what the --enable-kawa-frontend configure option does. It compiles a C program as a front-end to Kawa. This front-end program uses GNU readline. There may be some portability issues with the frontend - I haven't made any effort to port it, and it would certainly need major changes on Windows. More portable is the JLine2 support I recently announced. That is a 99%-pure-Java re-implementation of GNU readline. That gives you input editing, history, and (now) tab-completion. JLine2 may requires some native code on Windows; I haven't tried it under Windows yet. It should work out-of-the-box on most Unix-like OSes, including GNU/Linux and MacOS. (It should work on Windows too - I just don't have the instructions for doing that.) -- --Per Bothner per@bothner.com http://per.bothner.com/ ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: tab-completion implemented for Kawa 2016-02-25 23:51 ` Per Bothner @ 2016-02-26 0:48 ` Andrea Bernardini 0 siblings, 0 replies; 4+ messages in thread From: Andrea Bernardini @ 2016-02-26 0:48 UTC (permalink / raw) To: Per Bothner; +Cc: kawa On Thu, 25 Feb 2016 15:51:34 -0800 Per Bothner <per@bothner.com> wrote: > On 02/25/2016 03:33 PM, Andrea Bernardini wrote: > > Hi Per, > > This is a very nice feature! > > Thanks! > > > > 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. > > That what the arrow keys are supposed to send. However, Java doesn't > have a portable pure-Java mechanism to interpret those key sequences. > > > 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? > > That's what the --enable-kawa-frontend configure option does. It > compiles a C program as a front-end to Kawa. This front-end program > uses GNU readline. There may be some portability issues with the > frontend - I haven't made any effort to port it, and it would > certainly need major changes on Windows. Interesting. I just tried on Debian, it works, thanks > More portable is the JLine2 support I recently announced. That is a > 99%-pure-Java re-implementation of GNU readline. That gives you > input editing, history, and (now) tab-completion. This works too, and with the tab completion indeed, great! ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-26 0:48 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2016-02-25 2:13 tab-completion implemented for Kawa Per Bothner [not found] ` <CAPFJfsva4VPt_RQ5NrNzY8n7oyZB0EGL7VuFAzsEcGS8ruDqbA@mail.gmail.com> [not found] ` <CAPFJfsvV+Lnrko6Bj008DLA7007of_1a-XOM0oAYH5JTXrFRpA@mail.gmail.com> 2016-02-25 23:33 ` Andrea Bernardini 2016-02-25 23:51 ` Per Bothner 2016-02-26 0:48 ` Andrea Bernardini
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).