[code] [textadept] New Code Autocompletion "Framework"

From: Mitchell <m.att.foicica.com>
Date: Sun, 25 May 2014 19:53:27 -0400 (EDT)

Hi,

Adeptsense was an interesting experiment when it was first introduced in
version 3.7 beta (early 2011). While providing a generic interface for
autocompleting code in most languages, it was a fairly large framework,
and made a number of compromises. Since then, in writing Adeptsenses, I
find that I'm subclassing/redefining most Adeptsense functions, which is
pretty much defeating the purpose of the framework. Also, the
documentation heavily suggests providing a ctags-like "tags" file in order
to auto-load completions. While Adeptsense can transform tags into
completions quite well, generating such files (particularly by hand) is
annoying at best. Finally, let's not kid ourselves -- Adeptsense is far
from accurate on enough occasions to be obnoxious, especially when a
trigger character unexpectedly pops up an inaccurate completion list.

In an attempt to improve the situation, I've committed code[1] to hg that
removes Adeptsense and adds a single, new `autocomplete()` function to the
`textadept.editing` module. This function makes use of "autocompleter"
functions in a new `textadept.editing.autocompleters` table. When an
autocompleter function is called, it has complete control in determining a
symbol's context and producing a set of potential (and hopefully more
accurate) completions. Language modules will typically add a
language-specific autocompleter function. Examples for ANSI C and Lua
autocompleters are here[2] and here[3], respectively. I've also updated
the CSS, HTML, Python, and reST modules to define autocompleter functions.
There are no longer any trigger characters that automatically pop-up
completions either. If you prefer such functionality, you can add your own
`events.CHAR_ADDED` handler to do it for a specific lexer(s). If you have
custom key bindings that called on Adeptsense, please update your
bindings. An example is here[4].

In particular, I hope these changes enable one to more easily add
autocompletion support for other languages (1 simple function that
leverages ta's existing API vs. learning the Adeptsense framework...).

I've placed the legacy Adeptsense code and language modules that used it
on the wiki[5] for anyone who'd like to keep using it. However, please
note they will no longer be maintained.

All of this should be available starting in tonight's nightly, assuming it
builds properly with some of the other changes I committed.

Any feedback is welcome. If I'm making a horrible mistake, I'd like to
hear that too.

Cheers,
Mitchell

[1]: http://foicica.com/hg/textadept/rev/90ce05a9a8e3
[2]: http://foicica.com/hg/textadept/file/64659f74d23c/modules/ansi_c/init.lua
[3]: http://foicica.com/hg/textadept/file/64659f74d23c/modules/lua/init.lua
[4]: http://foicica.com/hg/textadept/diff/64659f74d23c/modules/textadept/keys.lua
[5]: http://foicica.com/wiki/adeptsense

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Sun 25 May 2014 - 19:53:27 EDT

This archive was generated by hypermail 2.2.0 : Mon 26 May 2014 - 06:32:12 EDT