aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept/command_entry.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2010-11-23 19:09:21 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2010-11-23 19:09:21 -0500
commit5f29cb8190dbee6bb10b4eb904c8c39750de352d (patch)
treeef9d178b4834087d829702d4894ec3b9330f3c0b /modules/textadept/command_entry.lua
parent1f3bbef0357b89f82a65d1e67caa1980eee3f40b (diff)
downloadtextadept-5f29cb8190dbee6bb10b4eb904c8c39750de352d.tar.gz
textadept-5f29cb8190dbee6bb10b4eb904c8c39750de352d.zip
Code cleanup.
Also modified the editing module's enclose() and select_enclosed() functions.
Diffstat (limited to 'modules/textadept/command_entry.lua')
-rw-r--r--modules/textadept/command_entry.lua20
1 files changed, 12 insertions, 8 deletions
diff --git a/modules/textadept/command_entry.lua b/modules/textadept/command_entry.lua
index c18550e9..d8a48616 100644
--- a/modules/textadept/command_entry.lua
+++ b/modules/textadept/command_entry.lua
@@ -3,6 +3,9 @@
local locale = _G.locale
+-- Environment for abbreviated commands.
+-- @class table
+-- @name env
local env = setmetatable({}, {
__index = function(t, k)
local f = buffer[k]
@@ -46,37 +49,38 @@ events.connect('command_entry_keypress',
local path, o, prefix = substring:match('^([%w_.:]-)([.:]?)([%w_]*)$')
local f, err = loadstring('return ('..path..')')
if type(f) == "function" then setfenv(f, env) end
- local ret, tbl = pcall(f)
+ local ok, tbl = pcall(f)
local cmpls = {}
- if not ret then -- shorthand notation
+ prefix = '^'..prefix
+ if not ok then -- shorthand notation
for _, t in ipairs{ buffer, view, gui, _G } do
for k in pairs(t) do
- if type(k) == 'string' and k:find('^'..prefix) then
+ if type(k) == 'string' and k:find(prefix) then
cmpls[#cmpls + 1] = k
end
end
end
for f in pairs(_SCINTILLA.functions) do
- if f:find('^'..prefix) then cmpls[#cmpls + 1] = f end
+ if f:find(prefix) then cmpls[#cmpls + 1] = f end
end
for p in pairs(_SCINTILLA.properties) do
- if p:find('^'..prefix) then cmpls[#cmpls + 1] = p end
+ if p:find(prefix) then cmpls[#cmpls + 1] = p end
end
else
if type(tbl) ~= 'table' then return end
for k in pairs(tbl) do
- if type(k) == 'string' and k:find('^'..prefix) then
+ if type(k) == 'string' and k:find(prefix) then
cmpls[#cmpls + 1] = k
end
end
if path == 'buffer' then
if o == ':' then
for f in pairs(_SCINTILLA.functions) do
- if f:find('^'..prefix) then cmpls[#cmpls + 1] = f end
+ if f:find(prefix) then cmpls[#cmpls + 1] = f end
end
else
for p in pairs(_SCINTILLA.properties) do
- if p:find('^'..prefix) then cmpls[#cmpls + 1] = p end
+ if p:find(prefix) then cmpls[#cmpls + 1] = p end
end
end
end