From 25d8542e87d1549128134cfb50e1bdc2423d3cec Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Thu, 6 Sep 2007 21:17:24 -0400 Subject: Words can be autocompleted from a specified dictionary. --- modules/textadept/editing.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'modules/textadept/editing.lua') diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua index d15ebb9b..ac9037da 100644 --- a/modules/textadept/editing.lua +++ b/modules/textadept/editing.lua @@ -107,7 +107,26 @@ function autocomplete_word(word_chars) end match_pos = buffer:find(root, 1048580, match_pos + 1) end - if #c_list_str > 0 then buffer:auto_c_show(#root, c_list_str:sub(1, -2)) end + if #c_list_str > 0 then buffer:auto_c_show( #root, c_list_str:sub(1, -2) ) end +end + +--- +-- Pops up an autocompletion list for the current word based on the path to a +-- dictionary of words. +-- @param dict Path to a dictionary of words. +function autocomplete_word_from_dict(dict) + local buffer = buffer + local start = buffer:word_start_position(buffer.current_pos, true) + local root = buffer:text_range(start, buffer.current_pos) + if #root == 0 then return end + local f = io.open(dict) + if not f then return end + local c_list_str = '' + for line in f:lines() do + if line:match('^'..root) then c_list_str = c_list_str..line..' ' end + end + f:close() + if #c_list_str > 0 then buffer:auto_c_show( #root, c_list_str:sub(1, -2) ) end end --- -- cgit v1.2.3