aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+667e-11@users.noreply.github.com>2009-01-10 17:31:21 -0500
committerGravatar mitchell <70453897+667e-11@users.noreply.github.com>2009-01-10 17:31:21 -0500
commitac698c5ea71d26e56289a18e664c6f8be1aa56c5 (patch)
treee683366e29ff29e8c0ebff54731ff505c201a6ff /modules
parent0194a626fcb17bcb037341fc6c2f586f54d26035 (diff)
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')
-rw-r--r--modules/cpp/commands.lua2
-rw-r--r--modules/lua/commands.lua32
-rw-r--r--modules/textadept/bookmarks.lua4
-rw-r--r--modules/textadept/editing.lua5
-rw-r--r--modules/textadept/lsnippets.lua2
-rw-r--r--modules/textadept/macros.lua7
-rw-r--r--modules/textadept/snippets.lua2
7 files changed, 40 insertions, 14 deletions
diff --git a/modules/cpp/commands.lua b/modules/cpp/commands.lua
index 09ea1dfe..d1e2fd17 100644
--- a/modules/cpp/commands.lua
+++ b/modules/cpp/commands.lua
@@ -1,5 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
+local textadept = _G.textadept
+
---
-- Commands for the cpp module.
module('_m.cpp.commands', package.seeall)
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
diff --git a/modules/textadept/bookmarks.lua b/modules/textadept/bookmarks.lua
index 8bcd3e7d..80853c29 100644
--- a/modules/textadept/bookmarks.lua
+++ b/modules/textadept/bookmarks.lua
@@ -1,5 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
+local textadept = _G.textadept
+
---
-- Bookmarks for the textadept module.
-- There are several option variables used:
@@ -48,6 +50,7 @@ end
---
-- Goes to the next bookmark in the current buffer.
function goto_next()
+ local buffer = buffer
local current_line = buffer:line_from_position(buffer.current_pos)
local line = buffer:marker_next(current_line + 1, 1)
if line >= 0 then _m.textadept.editing.goto_line(line + 1) end
@@ -56,6 +59,7 @@ end
---
-- Goes to the previous bookmark in the current buffer.
function goto_prev()
+ local buffer = buffer
local current_line = buffer:line_from_position(buffer.current_pos)
local line = buffer:marker_previous(current_line - 1, 1)
if line >= 0 then _m.textadept.editing.goto_line(line + 1) end
diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua
index 47166cf5..069135b2 100644
--- a/modules/textadept/editing.lua
+++ b/modules/textadept/editing.lua
@@ -1,5 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
+local textadept = _G.textadept
+
---
-- Editing commands for the textadept module.
module('_m.textadept.editing', package.seeall)
@@ -232,7 +234,8 @@ end
-- Goes to the requested line.
-- @param line Optional line number to go to.
function goto_line(line)
- local buffer, locale = buffer, textadept.locale
+ local buffer = buffer
+ local locale = textadept.locale
if not line then
line =
cocoa_dialog('standard-inputbox', {
diff --git a/modules/textadept/lsnippets.lua b/modules/textadept/lsnippets.lua
index 47819ae5..ee7a394b 100644
--- a/modules/textadept/lsnippets.lua
+++ b/modules/textadept/lsnippets.lua
@@ -1,5 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
+local textadept = _G.textadept
+
---
-- Provides Lua-centric snippets for Textadept.
-- Snippets are basically pieces of text inserted into a document, but can
diff --git a/modules/textadept/macros.lua b/modules/textadept/macros.lua
index 978a3482..62f9f972 100644
--- a/modules/textadept/macros.lua
+++ b/modules/textadept/macros.lua
@@ -1,5 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
+local textadept = _G.textadept
+
---
-- Support for recording, saving, and playing macros for the textadept module.
--
@@ -63,7 +65,7 @@ function stop_recording()
if not recording then return end
buffer:stop_record()
recording = false
- local textadept, locale = textadept, textadept.locale
+ local locale = textadept.locale
local ret, macro_name =
cocoa_dialog('standard-inputbox', {
['informative-text'] = locale.M_TEXTADEPT_MACRO_SAVE_TITLE,
@@ -117,7 +119,8 @@ function play(macro_name)
end
local macro = list[macro_name]
if not macro then return end
- local buffer, bf = buffer, textadept.buffer_functions
+ local buffer = buffer
+ local bf = textadept.buffer_functions
for _, command in ipairs(macro) do
local cmd, wParam, lParam = unpack(command)
local _, _, p1_type, p2_type = unpack(bf[cmd])
diff --git a/modules/textadept/snippets.lua b/modules/textadept/snippets.lua
index ec8cd11a..8d46610e 100644
--- a/modules/textadept/snippets.lua
+++ b/modules/textadept/snippets.lua
@@ -1,5 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
+local textadept = _G.textadept
+
---
-- Provides Textmate-like snippets for the textadept module.
-- There are several option variables used: