diff options
author | 2013-08-31 00:47:12 -0400 | |
---|---|---|
committer | 2013-08-31 00:47:12 -0400 | |
commit | d633a4c74e824113f5d242cb18573fed3015bc27 (patch) | |
tree | 41c05e5b83036493d61e68871dc3b011dd71bf03 /modules | |
parent | a54200e99b529d2fbbee6e27fabcb2e8de908c19 (diff) | |
download | textadept-d633a4c74e824113f5d242cb18573fed3015bc27.tar.gz textadept-d633a4c74e824113f5d242cb18573fed3015bc27.zip |
Allow user scripts to handle `BUFFER_NEW` and `VIEW_NEW` events on startup.
A side effect is more efficient event emission during startup.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/textadept/bookmarks.lua | 1 | ||||
-rw-r--r-- | modules/textadept/editing.lua | 1 | ||||
-rw-r--r-- | modules/textadept/file_types.lua | 1 | ||||
-rw-r--r-- | modules/textadept/init.lua | 8 | ||||
-rw-r--r-- | modules/textadept/keys.lua | 16 | ||||
-rw-r--r-- | modules/textadept/run.lua | 1 | ||||
-rw-r--r-- | modules/textadept/snippets.lua | 7 |
7 files changed, 14 insertions, 21 deletions
diff --git a/modules/textadept/bookmarks.lua b/modules/textadept/bookmarks.lua index 852c0df9..4e2d7b03 100644 --- a/modules/textadept/bookmarks.lua +++ b/modules/textadept/bookmarks.lua @@ -73,7 +73,6 @@ local function set_bookmark_properties() if CURSES then buffer:marker_define(MARK_BOOKMARK, CURSES_MARK) end buffer.marker_back[MARK_BOOKMARK] = buffer.property_int[M.BOOKMARK_COLOR] end -if buffer then set_bookmark_properties() end events.connect(events.VIEW_NEW, set_bookmark_properties) return M diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua index 670eecec..36dee287 100644 --- a/modules/textadept/editing.lua +++ b/modules/textadept/editing.lua @@ -509,7 +509,6 @@ local function set_highlight_properties() buffer.indic_alpha[INDIC_HIGHLIGHT] = 255 if not CURSES then buffer.indic_under[INDIC_HIGHLIGHT] = true end end -if buffer then set_highlight_properties() end events.connect(events.VIEW_NEW, set_highlight_properties) --- diff --git a/modules/textadept/file_types.lua b/modules/textadept/file_types.lua index f28e9d29..d4f6df57 100644 --- a/modules/textadept/file_types.lua +++ b/modules/textadept/file_types.lua @@ -111,7 +111,6 @@ local function set_lexer_functions() buffer.get_style_name = get_style_name end events.connect(events.BUFFER_NEW, set_lexer_functions, 1) -set_lexer_functions() -- for the first buffer -- Auto-detect lexer on file open or save as. events.connect(events.FILE_OPENED, function() buffer:set_lexer() end) diff --git a/modules/textadept/init.lua b/modules/textadept/init.lua index 9dd072b7..b3049a49 100644 --- a/modules/textadept/init.lua +++ b/modules/textadept/init.lua @@ -19,8 +19,10 @@ M.run = require('textadept.run') M.session = require('textadept.session') M.snippets = require('textadept.snippets') --- These need to be loaded last. -M.keys = require('textadept.keys') -M.menu = require('textadept.menu') +events.connect(events.INITIALIZED, function() + -- These need to be loaded last. + M.keys = require('textadept.keys') + M.menu = require('textadept.menu') +end) return M 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. -- diff --git a/modules/textadept/run.lua b/modules/textadept/run.lua index 6a66e8d3..e253a6c9 100644 --- a/modules/textadept/run.lua +++ b/modules/textadept/run.lua @@ -250,7 +250,6 @@ local function set_error_properties() if CURSES then buffer:marker_define(MARK_ERROR, CURSES_MARK) end buffer.marker_back[MARK_ERROR] = buffer.property_int[M.ERROR_COLOR] end -if buffer then set_error_properties() end events.connect(events.VIEW_NEW, set_error_properties) return M diff --git a/modules/textadept/snippets.lua b/modules/textadept/snippets.lua index 76c36223..4827c8c8 100644 --- a/modules/textadept/snippets.lua +++ b/modules/textadept/snippets.lua @@ -368,10 +368,9 @@ M._snippet_mt = { end, } -local INDIC_HIDDEN = buffer.INDIC_HIDDEN -if buffer then buffer.indic_style[INDIC_SNIPPET] = INDIC_HIDDEN end -events.connect(events.VIEW_NEW, - function() buffer.indic_style[INDIC_SNIPPET] = INDIC_HIDDEN end) +events.connect(events.VIEW_NEW, function() + buffer.indic_style[INDIC_SNIPPET] = buffer.INDIC_HIDDEN +end) --- -- Map of snippet triggers with their snippet text, with language-specific |