From d633a4c74e824113f5d242cb18573fed3015bc27 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Sat, 31 Aug 2013 00:47:12 -0400 Subject: Allow user scripts to handle `BUFFER_NEW` and `VIEW_NEW` events on startup. A side effect is more efficient event emission during startup. --- modules/textadept/keys.lua | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'modules/textadept/keys.lua') diff --git a/modules/textadept/keys.lua b/modules/textadept/keys.lua index 95f182ab..27f44c86 100644 --- a/modules/textadept/keys.lua +++ b/modules/textadept/keys.lua @@ -289,6 +289,11 @@ M.utils = { buffer:cut() end } + +local keys, buffer, view = keys, buffer, view +local editing, utils = textadept.editing, M.utils +local OSX, CURSES = OSX, CURSES + -- The following buffer functions need to be constantized in order for menu -- items to identify the key associated with the functions. local menu_buffer_functions = { @@ -296,16 +301,7 @@ local menu_buffer_functions = { 'select_all', 'upper_case', 'lower_case', 'move_selected_lines_up', 'move_selected_lines_down', 'zoom_in', 'zoom_out', 'colourise' } -local function constantize_menu_buffer_functions() - local buffer = buffer - for _, f in ipairs(menu_buffer_functions) do buffer[f] = buffer[f] end -end -events.connect(events.BUFFER_NEW, constantize_menu_buffer_functions) -constantize_menu_buffer_functions() -- for the first buffer - -local keys, buffer, view = keys, buffer, view -local editing, utils = textadept.editing, M.utils -local OSX, CURSES = OSX, CURSES +for _, f in ipairs(menu_buffer_functions) do buffer[f] = buffer[f] end -- Windows and Linux key bindings. -- -- cgit v1.2.3