public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* 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

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).