From ac698c5ea71d26e56289a18e664c6f8be1aa56c5 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Sat, 10 Jan 2009 17:31:21 -0500 Subject: 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. --- modules/lua/commands.lua | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'modules/lua/commands.lua') 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 mitchellcaladbolg.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 -- cgit v1.2.3