public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Per Bothner <per@bothner.com>
To: Kawa mailing list <kawa@sourceware.org>
Subject: tab-completion implemented for Kawa
Date: Thu, 25 Feb 2016 02:13:00 -0000	[thread overview]
Message-ID: <56CE6324.80502@bothner.com> (raw)

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/

             reply	other threads:[~2016-02-25  2:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-25  2:13 Per Bothner [this message]
     [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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56CE6324.80502@bothner.com \
    --to=per@bothner.com \
    --cc=kawa@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).