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. --- core/ext/pm/buffer_browser.lua | 13 +++++++------ core/ext/pm/ctags_browser.lua | 11 ++++++----- core/ext/pm/file_browser.lua | 2 ++ core/ext/pm/find_browser.lua | 2 ++ core/ext/pm/macro_browser.lua | 9 ++++----- core/ext/pm/modules_browser.lua | 3 ++- core/ext/pm/project_browser.lua | 2 ++ 7 files changed, 25 insertions(+), 17 deletions(-) (limited to 'core/ext/pm') diff --git a/core/ext/pm/buffer_browser.lua b/core/ext/pm/buffer_browser.lua index 73b09d55..83bb26f9 100644 --- a/core/ext/pm/buffer_browser.lua +++ b/core/ext/pm/buffer_browser.lua @@ -1,5 +1,7 @@ -- Copyright 2007-2009 Mitchell mitchellcaladbolg.net. See LICENSE. +local textadept = _G.textadept + --- -- Buffer browser for the Textadept project manager. -- It is enabled with the prefix 'buffers' in the project manager entry field. @@ -62,12 +64,11 @@ function perform_menu_action(menu_item, menu_id, selected_item) textadept.pm.activate() end -local add_handler = textadept.events.add_handler local function update_view() if matches(textadept.pm.entry_text) then textadept.pm.activate() end end -add_handler('file_opened', update_view) -add_handler('buffer_new', update_view) -add_handler('buffer_deleted', update_view) -add_handler('save_point_reached', update_view) -add_handler('save_point_left', update_view) +textadept.events.add_handler('file_opened', update_view) +textadept.events.add_handler('buffer_new', update_view) +textadept.events.add_handler('buffer_deleted', update_view) +textadept.events.add_handler('save_point_reached', update_view) +textadept.events.add_handler('save_point_left', update_view) diff --git a/core/ext/pm/ctags_browser.lua b/core/ext/pm/ctags_browser.lua index e1b4586d..8f112470 100644 --- a/core/ext/pm/ctags_browser.lua +++ b/core/ext/pm/ctags_browser.lua @@ -1,5 +1,7 @@ -- Copyright 2007-2009 Mitchell mitchellcaladbolg.net. See LICENSE. +local textadept = _G.textadept + --- -- CTags Browser for the Textadept project manager. -- It is enabled with the prefix 'ctags' in the project manager entry field @@ -234,7 +236,6 @@ function perform_menu_action(menu_item, menu_id, selected_item) end -local add_handler = textadept.events.add_handler local function update_view() if matches(textadept.pm.entry_text) then if buffer.filename then @@ -244,7 +245,7 @@ local function update_view() end end end -add_handler('file_opened', update_view) -add_handler('buffer_deleted', update_view) -add_handler('buffer_switch', update_view) -add_handler('save_point_reached', update_view) +textadept.events.add_handler('file_opened', update_view) +textadept.events.add_handler('buffer_deleted', update_view) +textadept.events.add_handler('buffer_switch', update_view) +textadept.events.add_handler('save_point_reached', update_view) diff --git a/core/ext/pm/file_browser.lua b/core/ext/pm/file_browser.lua index c658b6c0..87d4b8e6 100644 --- a/core/ext/pm/file_browser.lua +++ b/core/ext/pm/file_browser.lua @@ -1,5 +1,7 @@ -- Copyright 2007-2009 Mitchell mitchellcaladbolg.net. See LICENSE. +local textadept = _G.textadept + --- -- File browser for the Textadept project manager. -- It is enabled by providing the absolute path to a directory in the project diff --git a/core/ext/pm/find_browser.lua b/core/ext/pm/find_browser.lua index a8722e78..c79ab167 100644 --- a/core/ext/pm/find_browser.lua +++ b/core/ext/pm/find_browser.lua @@ -1,5 +1,7 @@ -- Copyright 2007-2009 Mitchell mitchellcaladbolg.net. See LICENSE. +local textadept = _G.textadept + --- -- Find in files browser for the Textadept project manager. -- It is enabled with the prefix 'find' in the project manager entry field. diff --git a/core/ext/pm/macro_browser.lua b/core/ext/pm/macro_browser.lua index c2892fa7..051487cf 100644 --- a/core/ext/pm/macro_browser.lua +++ b/core/ext/pm/macro_browser.lua @@ -1,12 +1,12 @@ -- Copyright 2007-2009 Mitchell mitchellcaladbolg.net. See LICENSE. +local textadept = _G.textadept + --- -- Macro browser for the Textadept project manager. -- It is enabled with the prefix 'macros' in the project manager entry field. module('textadept.pm.browsers.macro', package.seeall) -local textadept = textadept - function matches(entry_text) return entry_text:sub(1, 7) == 'macros' end @@ -38,9 +38,8 @@ function perform_menu_action(menu_item, menu_id, selected_item) textadept.pm.activate() end -local add_handler = textadept.events.add_handler local function update_view() if matches(textadept.pm.entry_text) then textadept.pm.activate() end end -add_handler('macro_saved', update_view) -add_handler('macro_deleted', update_view) +textadept.events.add_handler('macro_saved', update_view) +textadept.events.add_handler('macro_deleted', update_view) diff --git a/core/ext/pm/modules_browser.lua b/core/ext/pm/modules_browser.lua index 4fc97206..757e7d93 100644 --- a/core/ext/pm/modules_browser.lua +++ b/core/ext/pm/modules_browser.lua @@ -1,5 +1,7 @@ -- Copyright 2007-2009 Mitchell mitchellcaladbolg.net. See LICENSE. +local textadept = _G.textadept + --- -- Modules browser for the Textadept project manager. -- It is enabled with the prefix 'modules' in the project manager entry field. @@ -182,7 +184,6 @@ function perform_menu_action(menu_item, menu_id, selected_item) elseif menu_id == ID.CONF_MIME_TYPES then textadept.io.open(_HOME..'/core/ext/mime_types.lua') elseif menu_id == ID.CONF_KEY_COMMANDS then - local textadept = textadept if textadept.key_commands then textadept.io.open(_HOME..'/core/ext/key_commands.lua') elseif textadept.key_commands_std then diff --git a/core/ext/pm/project_browser.lua b/core/ext/pm/project_browser.lua index 30c6a847..0219839e 100644 --- a/core/ext/pm/project_browser.lua +++ b/core/ext/pm/project_browser.lua @@ -1,5 +1,7 @@ -- Copyright 2007-2009 Mitchell mitchellcaladbolg.net. See LICENSE. +local textadept = _G.textadept + --- -- Browser template for the Textadept project manager. -- It is enabled with the prefix 'project' in the project manager entry field. -- cgit v1.2.3