aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept/editing.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2007-09-06 21:17:24 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2007-09-06 21:17:24 -0400
commit25d8542e87d1549128134cfb50e1bdc2423d3cec (patch)
treefeec09a67eb682762dcbf03b332b8c6b83f83355 /modules/textadept/editing.lua
parentc6dd9855e1a41357cf672de0b291925c456f43a4 (diff)
downloadtextadept-25d8542e87d1549128134cfb50e1bdc2423d3cec.tar.gz
textadept-25d8542e87d1549128134cfb50e1bdc2423d3cec.zip
Words can be autocompleted from a specified dictionary.
Diffstat (limited to 'modules/textadept/editing.lua')
-rw-r--r--modules/textadept/editing.lua21
1 files changed, 20 insertions, 1 deletions
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
---