Re: [code] Auto-complete from all open buffers

From: Mitchell <>
Date: Wed, 26 Jun 2013 09:34:28 -0400 (Eastern Daylight Time)


On Mon, 24 Jun 2013, Ryan Pusztai wrote:

> Hi Mitchell,
> On Mon, Jun 24, 2013 at 3:18 PM, Mitchell <> wrote:
>> It is possible, but difficult. You cannot grab the text from non-focused
>> buffers using the API or you'll get an error. Instead you can either cycle
>> through all buffers to get word matches on demand (ugly and disorienting),
>> or perhaps compile a word list in an `events.BUFFER_BEFORE_SWITCH` event
>> and query that and the currently focused buffer.
> Is there a function to call that creates the word list?

Take a look at modules/textadept/editing.lua which uses the Scintilla API
to find words. You can either use something like that or just grab all
buffer text with `buffer:get_text()` and use Lua's `gmatch('[%w_]+')` or
similar to build the list.

I'm not sure which approach is more efficient. Using `buffer:get_text()`
duplicates buffer text in memory so consider that for large buffers.


You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Wed 26 Jun 2013 - 09:34:28 EDT

This archive was generated by hypermail 2.2.0 : Thu 27 Jun 2013 - 06:37:56 EDT