diff options
author | mitchell <70453897+667e-11@users.noreply.github.com> | 2010-04-05 15:32:33 -0400 |
---|---|---|
committer | mitchell <70453897+667e-11@users.noreply.github.com> | 2010-04-05 15:32:33 -0400 |
commit | c9780bff7285d4bf756c689229add52b4701570b (patch) | |
tree | 8d491e3eb516fde0b5dac4786003016504d13404 | |
parent | e20531bcb0cdd582c82a5083f917fb1b94557087 (diff) |
Code cleanup.
-rw-r--r-- | core/events.lua | 1 | ||||
-rw-r--r-- | core/ext/key_commands.lua | 6 | ||||
-rw-r--r-- | core/init.lua | 10 | ||||
-rw-r--r-- | doc/manual/1_Introduction.md | 2 | ||||
-rw-r--r-- | init.lua | 15 | ||||
-rw-r--r-- | modules/textadept/editing.lua | 12 | ||||
-rw-r--r-- | modules/textadept/session.lua | 2 |
7 files changed, 15 insertions, 33 deletions
diff --git a/core/events.lua b/core/events.lua index 3cc47e29..7deac1a2 100644 --- a/core/events.lua +++ b/core/events.lua @@ -337,7 +337,6 @@ add_handler('update_ui', add_handler('margin_click', function(margin, modifiers, position) -- toggles folding - local buffer = buffer local line = buffer:line_from_position(position) buffer:toggle_fold(line) end) diff --git a/core/ext/key_commands.lua b/core/ext/key_commands.lua index 7150be0c..162f97a9 100644 --- a/core/ext/key_commands.lua +++ b/core/ext/key_commands.lua @@ -210,7 +210,7 @@ if not MAC then keys['f2'] = { t.command_entry.focus } -- Run local m_run = _m.textadept.run - keys.cr = { m_run.run } + keys.cr = { m_run.run } keys.cR = { m_run.compile } -- Snippets local m_snippets = _m.textadept.lsnippets @@ -281,7 +281,7 @@ else -- Mac OSX key commands --[[ - C: J L M U W X Z + C: J M U W X Z A: D E H J K L U CS: C D G H I J K L M O Q S T U V W X Y Z SA: A B C D H I J K L M N O Q R T U V X @@ -355,7 +355,7 @@ else } -- Search - keys.af = { t.find.focus } -- find/replace + keys.af = { t.find.focus } -- find/replace keys.ag = { t.find.find_next } keys.aG = { t.find.find_prev } keys.ar = { t.find.replace } diff --git a/core/init.lua b/core/init.lua index f17ec196..25708169 100644 --- a/core/init.lua +++ b/core/init.lua @@ -15,16 +15,14 @@ _LEXERPATH = _USERHOME..'/lexers/?.lua;'.._HOME..'/lexers' _THEME = 'light' local f = io.open(_USERHOME..'/theme', 'rb') if f then - theme = f:read('*line'):match('[^\r\n]+') + local theme = f:read('*line'):match('[^\r\n]+') f:close() if theme and #theme > 0 then _THEME = theme end end -theme = _THEME -if not theme:find('[/\\]') then +if not _THEME:find('[/\\]') then + local theme = _THEME _THEME = _HOME..'/themes/'..theme - if not lfs.attributes(_THEME) then - _THEME = _USERHOME..'/themes/'..theme - end + if not lfs.attributes(_THEME) then _THEME = _USERHOME..'/themes/'..theme end end require 'iface' diff --git a/doc/manual/1_Introduction.md b/doc/manual/1_Introduction.md index 7d61bfb6..050950e0 100644 --- a/doc/manual/1_Introduction.md +++ b/doc/manual/1_Introduction.md @@ -13,7 +13,7 @@ its number of features, Textadept breaks that trend, aiming to stay minimalist and fast, but at the same time being ridiculously extensible. At its core lies less than 2000 lines of C code, and that's how it always will be. While other editors rely on feature bloat, recordable macros to speed up workflow, and shell -scripts to quickly transform text. Textadept takes it to the extreme: it gives +scripts to quickly transform text, Textadept takes it to the extreme: it gives you complete control over the entire application using the embedded [Lua][Lua] language. Lua is nearly as fast as C, and has a very small footprint. In fact, most of Textadept is written in Lua. Its incredibly fast startup time and @@ -33,16 +33,13 @@ if not RESETTING then if WIN32 and #arg[0] > 0 then local lpeg = require 'lpeg' local P, C = lpeg.P, lpeg.C - param = P('"') * C((1 - P('"'))^0) * '"' + C((1 - P(' '))^1) - cmdline = lpeg.Ct(param * (P(' ') * param)^0) - args = lpeg.match(cmdline, arg[0]) + local param = P('"') * C((1 - P('"'))^0) * '"' + C((1 - P(' '))^1) + local args = lpeg.match(lpeg.Ct(param * (P(' ') * param)^0), arg[0]) for _, a in ipairs(args) do arg[#arg + 1] = a end end -- process command line arguments - if MAC and arg[1] and arg[1]:find('^%-psn_0') then - table.remove(arg, 1) - end + if MAC and arg[1] and arg[1]:find('^%-psn_0') then table.remove(arg, 1) end if #arg == 0 then _m.textadept.session.load() else @@ -55,10 +52,6 @@ if not RESETTING then end -- open files - local base_dir = arg[0]:match('^.+/') or '' - for _, filename in ipairs(arg) do - if not filename:find('^~?/') then filename = base_dir..filename end - textadept.io.open(filename) - end + for _, filename in ipairs(arg) do textadept.io.open(filename) end end end diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua index 553bc824..6803dc40 100644 --- a/modules/textadept/editing.lua +++ b/modules/textadept/editing.lua @@ -80,8 +80,7 @@ textadept.events.add_handler('char_added', end) textadept.events.add_handler('keypress', - function(code, shift, control, alt) - -- Backspace (from <gdk/gdkkeysyms.h>) + function(code, shift, control, alt) -- removes matched chars on backspace if AUTOPAIR and code == 0xff08 and buffer.selections == 1 then local buffer = buffer local current_pos = buffer.current_pos @@ -139,7 +138,7 @@ textadept.events.add_handler('char_added', -- local functions local insert_into_kill_ring, scroll_kill_ring -local get_preceding_number, get_sel_or_line +local get_preceding_number --- -- Goes to a matching brace position, selecting the text inside if specified. @@ -584,10 +583,3 @@ get_preceding_number = function() end return tonumber(txt) or 1, #txt end - --- Returns the current selection or the contents of the current line. -get_sel_or_line = function() - local buffer = buffer - if buffer:get_sel_text() == '' then select_line() end - return buffer:get_sel_text() -end diff --git a/modules/textadept/session.lua b/modules/textadept/session.lua index ed1cbe8e..af3d1887 100644 --- a/modules/textadept/session.lua +++ b/modules/textadept/session.lua @@ -167,4 +167,4 @@ function save(filename) end textadept.events.add_handler('quit', - function() if SAVE_ON_QUIT then save() end end, 1) + function() if SAVE_ON_QUIT then save() end end, 1) |