aboutsummaryrefslogtreecommitdiff
path: root/modules/lua/commands.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2009-01-10 17:31:21 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2009-01-10 17:31:21 -0500
commitac698c5ea71d26e56289a18e664c6f8be1aa56c5 (patch)
treee683366e29ff29e8c0ebff54731ff505c201a6ff /modules/lua/commands.lua
parent0194a626fcb17bcb037341fc6c2f586f54d26035 (diff)
downloadtextadept-ac698c5ea71d26e56289a18e664c6f8be1aa56c5.tar.gz
textadept-ac698c5ea71d26e56289a18e664c6f8be1aa56c5.zip
Various improvements to speed and readability of Lua code.
Added 'local textadept = _G.textadept' to all Lua modules, themes, etc. Added more locals to core/ext/keys.lua for speed improvement. Reformatted some Lua modules to the earlier standard committed.
Diffstat (limited to 'modules/lua/commands.lua')
-rw-r--r--modules/lua/commands.lua32
1 files changed, 21 insertions, 11 deletions
diff --git a/modules/lua/commands.lua b/modules/lua/commands.lua
index 654c6cfb..5e5fbc93 100644
--- a/modules/lua/commands.lua
+++ b/modules/lua/commands.lua
@@ -1,5 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
+local textadept = _G.textadept
+
---
-- Commands for the lua module.
module('_m.lua.commands', package.seeall)
@@ -21,16 +23,18 @@ local control_structure_patterns = {
function try_to_autocomplete_end()
local buffer = buffer
buffer:begin_undo_action()
- buffer:line_end() buffer:new_line()
+ buffer:line_end()
+ buffer:new_line()
local line_num = buffer:line_from_position(buffer.current_pos)
local line = buffer:get_line(line_num - 1)
for _, patt in ipairs(control_structure_patterns) do
if line:match(patt) then
local indent = buffer.line_indentation[line_num - 1]
- buffer:add_text( patt:match('repeat') and '\nuntil' or '\nend' )
+ buffer:add_text(patt:match('repeat') and '\nuntil' or '\nend')
buffer.line_indentation[line_num + 1] = indent
buffer.line_indentation[line_num] = indent + buffer.indent
- buffer:line_up() buffer:line_end()
+ buffer:line_up()
+ buffer:line_end()
break
end
end
@@ -54,7 +58,11 @@ function goto_required()
for path in package.path:gmatch('[^;]+') do
path = path:gsub('?', file)
local f = io.open(path)
- if f then f:close() textadept.io.open(path) break end
+ if f then
+ f:close()
+ textadept.io.open(path)
+ break
+ end
end
end
@@ -80,12 +88,14 @@ if type(keys) == 'table' then
},
['s\n'] = { try_to_autocomplete_end },
cg = { run },
- ['('] = { function()
- buffer.word_chars =
- '_.:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
- m_editing.show_call_tip(_m.lua.api, true)
- buffer:set_chars_default()
- return false
- end },
+ ['('] = {
+ function()
+ buffer.word_chars =
+ '_.:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
+ m_editing.show_call_tip(_m.lua.api, true)
+ buffer:set_chars_default()
+ return false
+ end
+ },
}
end