aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2010-04-08 20:01:44 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2010-04-08 20:01:44 -0400
commitd7d389404806cf9a512cbe2b7d9700fe983a40d6 (patch)
tree86201ce2d93ca01e8d236cd2f41c250ea8d483c9 /modules
parent9999a72d673df993948216b7ed79f9f77fc53f9d (diff)
downloadtextadept-d7d389404806cf9a512cbe2b7d9700fe983a40d6.tar.gz
textadept-d7d389404806cf9a512cbe2b7d9700fe983a40d6.zip
Respect tab settings for snippets.
Thanks to Rob Gieseke.
Diffstat (limited to 'modules')
-rw-r--r--modules/cpp/snippets.lua4
-rw-r--r--modules/lua/snippets.lua10
-rw-r--r--modules/textadept/lsnippets.lua5
3 files changed, 12 insertions, 7 deletions
diff --git a/modules/cpp/snippets.lua b/modules/cpp/snippets.lua
index 98eab9b0..1b91157d 100644
--- a/modules/cpp/snippets.lua
+++ b/modules/cpp/snippets.lua
@@ -13,8 +13,8 @@ if type(snippets) == 'table' then
cc = 'const_cast<%1>(%2(%(selected_text)))',
-- Lua snippets
- lf = 'static int %1(function)(lua_State *%2(lua)) {\n %0\n return 0;\n}',
- lff = 'LF %1(function)(lua_State *%2(lua)) {\n %0\n return 0;\n}',
+ lf = 'static int %1(function)(lua_State *%2(lua)) {\n\t%0\n\treturn 0;\n}',
+ lff = 'LF %1(function)(lua_State *%2(lua)) {\n\t%0\n\treturn 0;\n}',
ls = 'lua_State',
lgf = 'lua_getfield(%1(lua), %2(-1), %3(field));',
lgg = 'lua_getglobal(%1(lua), %2(global));',
diff --git a/modules/lua/snippets.lua b/modules/lua/snippets.lua
index 7b827f91..93f36078 100644
--- a/modules/lua/snippets.lua
+++ b/modules/lua/snippets.lua
@@ -10,14 +10,14 @@ if type(snippets) == 'table' then
snippets.lua = {
l = "local %1(expr)%2( = %3(value))",
p = "print(%0)",
- f = "function %1(name)(%2(args))\n %0\nend",
- fori = "for %1(i), %2(val) in ipairs(%3(table)) do\n %0\nend",
- ['for'] = "for i=%1(1), %2(10)%3(, -1) do\n %0\nend",
- forp = "for %1(k), %2(v) in pairs(%3(table)) do\n %0\nend",
+ f = "function %1(name)(%2(args))\n\t%0\nend",
+ fori = "for %1(i), %2(val) in ipairs(%3(table)) do\n\t%0\nend",
+ ['for'] = "for i=%1(1), %2(10)%3(, -1) do\n\t%0\nend",
+ forp = "for %1(k), %2(v) in pairs(%3(table)) do\n\t%0\nend",
find = "string.find(%1(str), %2(pattern))",
len = "string.len(%1(str))",
gsub = "string.gsub(%1(str), %2(pattern), %3(repl))",
- gfind = "for %1(match) in string.gfind(%2(str), %3(pattern)) do\n %0\nend",
+ gfind = "for %1(match) in string.gfind(%2(str), %3(pattern)) do\n\t%0\nend",
c = "-- ",
tc = "local %1(tc) = lunit.TestCase('%2(description)')",
diff --git a/modules/textadept/lsnippets.lua b/modules/textadept/lsnippets.lua
index 92f1b0a5..19f20e28 100644
--- a/modules/textadept/lsnippets.lua
+++ b/modules/textadept/lsnippets.lua
@@ -344,6 +344,11 @@ function insert(s_text)
buffer:begin_undo_action()
s_text = handle_escapes(s_text)
+ -- Take into account tab settings.
+ if not buffer.use_tabs then
+ s_text = s_text:gsub('\t', string.rep(' ', buffer.tab_width))
+ end
+
-- Execute Lua and shell code.
s_text = s_text:gsub('%%(%b())', run_lua_code)
s_text =