diff options
author | mitchell <70453897+667e-11@users.noreply.github.com> | 2011-11-23 08:22:55 -0500 |
---|---|---|
committer | mitchell <70453897+667e-11@users.noreply.github.com> | 2011-11-23 08:22:55 -0500 |
commit | 6d8d01a364ba9786b7f9698840ba60e769954808 (patch) | |
tree | 19afb5afac0889d6c1a92bb2c33ee551f902a134 | |
parent | f1db4cacfe3aa49ac03e50f05ea522e69b1a0b63 (diff) |
Code cleanup.
-rw-r--r-- | core/file_io.lua | 5 | ||||
-rw-r--r-- | core/gui.lua | 3 | ||||
-rw-r--r-- | core/keys.lua | 5 | ||||
-rw-r--r-- | modules/textadept/bookmarks.lua | 2 | ||||
-rw-r--r-- | modules/textadept/editing.lua | 16 | ||||
-rw-r--r-- | modules/textadept/filter_through.lua | 2 | ||||
-rw-r--r-- | modules/textadept/snippets.lua | 6 | ||||
-rw-r--r-- | scripts/adeptsensedoc.lua | 2 | ||||
-rwxr-xr-x | scripts/update_doc | 4 |
9 files changed, 18 insertions, 27 deletions
diff --git a/core/file_io.lua b/core/file_io.lua index 35140c5a..602c0f19 100644 --- a/core/file_io.lua +++ b/core/file_io.lua @@ -250,13 +250,12 @@ end -- Saves all dirty buffers to their respective files. -- @usage io.save_all() function save_all() - local current_buffer, current_index = buffer, 1 + local current_buffer = _BUFFERS[buffer] for i, buffer in ipairs(_BUFFERS) do view:goto_buffer(i) - if buffer == current_buffer then current_index = i end if buffer.filename and buffer.dirty then buffer:save() end end - view:goto_buffer(current_index) + view:goto_buffer(current_buffer) end -- LuaDoc is in core/.buffer.luadoc. diff --git a/core/gui.lua b/core/gui.lua index 3ebc63e5..4c9e26a1 100644 --- a/core/gui.lua +++ b/core/gui.lua @@ -272,8 +272,7 @@ connect(events.BUFFER_NEW, function() set_title(buffer) end) connect(events.BUFFER_BEFORE_SWITCH, function() local buffer = buffer -- Save view state. - buffer._anchor = buffer.anchor - buffer._current_pos = buffer.current_pos + buffer._anchor, buffer._current_pos = buffer.anchor, buffer.current_pos buffer._first_visible_line = buffer.first_visible_line -- Save fold state. buffer._folds = {} diff --git a/core/keys.lua b/core/keys.lua index a00beb7d..4d1ccf48 100644 --- a/core/keys.lua +++ b/core/keys.lua @@ -107,10 +107,7 @@ LANGUAGE_MODULE_PREFIX = (not OSX and CTRL or META)..'l' local OSX = OSX local string = string local string_byte, string_char = string.byte, string.char -local xpcall = xpcall -local next = next -local type = type -local unpack = unpack +local xpcall, next, type, unpack = xpcall, next, type, unpack local no_args = {} local getmetatable = getmetatable local error = function(e) events.emit(events.ERROR, e) end diff --git a/modules/textadept/bookmarks.lua b/modules/textadept/bookmarks.lua index fdf6b8b2..0e6ab017 100644 --- a/modules/textadept/bookmarks.lua +++ b/modules/textadept/bookmarks.lua @@ -78,7 +78,7 @@ function goto() if line == -1 then return end repeat local text = buffer:get_line(line):sub(1, -2) -- chop \n - markers[#markers + 1] = table.concat({ line + 1, text }, ': ') + markers[#markers + 1] = tostring(line + 1)..': '..text line = buffer:marker_next(line + 1, 2^MARK_BOOKMARK) until line < 0 local line = gui.filteredlist(L('Select Bookmark'), 'Bookmark', markers) diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua index 4d885a81..b6e8bf70 100644 --- a/modules/textadept/editing.lua +++ b/modules/textadept/editing.lua @@ -161,16 +161,12 @@ function match_brace(select) local buffer = buffer local caret = buffer.current_pos local match_pos = buffer:brace_match(caret) - if match_pos ~= -1 then - if select then - if match_pos > caret then - buffer:set_sel(caret, match_pos + 1) - else - buffer:set_sel(caret + 1, match_pos) - end - else - buffer:goto_pos(match_pos) - end + if match_pos == -1 then return end + if not select then caret = match_pos end + if match_pos > caret then + buffer:set_sel(caret, match_pos + 1) + else + buffer:set_sel(caret + 1, match_pos) end end diff --git a/modules/textadept/filter_through.lua b/modules/textadept/filter_through.lua index 35123194..bb55f444 100644 --- a/modules/textadept/filter_through.lua +++ b/modules/textadept/filter_through.lua @@ -52,7 +52,7 @@ events.connect(events.COMMAND_ENTRY_COMMAND, function(text) local f = io.open(tmpfile, 'wb') f:write(input) f:close() - local cmd = table.concat({ cat, '"'..tmpfile..'"', '|', text }, ' ') + local cmd = cat..' "'..tmpfile..'" | '..text if WIN32 then cmd = cmd:gsub('/', '\\') end local p = io.popen(cmd) if s ~= e then diff --git a/modules/textadept/snippets.lua b/modules/textadept/snippets.lua index 45f32d83..3763ab7c 100644 --- a/modules/textadept/snippets.lua +++ b/modules/textadept/snippets.lua @@ -214,17 +214,17 @@ end -- Global snippets and snippets in the current lexer are shown. function _select() local list = {} - local table_concat, type = table.concat, type + local type = type for trigger, text in pairs(snippets) do if type(text) == 'string' and trigger ~= '_NAME' and trigger ~= '_PACKAGE' then - list[#list + 1] = table_concat({trigger, 'global', text }, '\0') + list[#list + 1] = trigger..'\0global\0'..text end end local lexer = buffer:get_lexer() for trigger, text in pairs(snippets[lexer] or {}) do if type(text) == 'string' then - list[#list + 1] = table_concat({trigger, lexer, text }, '\0') + list[#list + 1] = trigger..'\0'..lexer..'\0'..text end end table.sort(list) diff --git a/scripts/adeptsensedoc.lua b/scripts/adeptsensedoc.lua index bb487fd1..ff930d69 100644 --- a/scripts/adeptsensedoc.lua +++ b/scripts/adeptsensedoc.lua @@ -78,7 +78,7 @@ local function write_apidoc(file, m, b) local p = io.popen(table.concat(doc, '\n')) doc = p:read('*all'):gsub('\n', '\\n') p:close() - file[#file + 1] = table.concat({ name:match('[^%.:]+$') , doc }, ' ') + file[#file + 1] = name:match('[^%.:]+$')..' '..doc end -- Called by LuaDoc to process a doc object. diff --git a/scripts/update_doc b/scripts/update_doc index 7ecd5617..5457c214 100755 --- a/scripts/update_doc +++ b/scripts/update_doc @@ -140,6 +140,6 @@ end -- Create Lua adeptsense for textadept. if adeptsense then - os.execute(table.concat{ 'luadoc -d ../modules/lua -doclet adeptsensedoc ', - '../modules ../core ../lexers/lexer.lua' }) + os.execute('luadoc -d ../modules/lua -doclet adeptsensedoc '.. + '../modules ../core ../lexers/lexer.lua') end |