aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/ext/key_commands.lua2
-rw-r--r--core/ext/menu.lua2
-rw-r--r--modules/textadept/run.lua28
3 files changed, 17 insertions, 15 deletions
diff --git a/core/ext/key_commands.lua b/core/ext/key_commands.lua
index 9f449679..265b5080 100644
--- a/core/ext/key_commands.lua
+++ b/core/ext/key_commands.lua
@@ -292,7 +292,7 @@ else
keys['f2'] = { t.command_entry.focus }
-- Run
local m_run = _m.textadept.run
- keys.cr = { m_run.go }
+ keys.cr = { m_run.run }
keys.csr = { m_run.compile }
-- Snippets
local m_snippets = _m.textadept.lsnippets
diff --git a/core/ext/menu.lua b/core/ext/menu.lua
index 37d1e7f4..3d5bc83c 100644
--- a/core/ext/menu.lua
+++ b/core/ext/menu.lua
@@ -403,7 +403,7 @@ local actions = {
[ID.GOTO_LINE] = { m_editing.goto_line },
-- Tools
[ID.FOCUS_COMMAND_ENTRY] = { t.command_entry.focus },
- [ID.RUN] = { m_run.go },
+ [ID.RUN] = { m_run.run },
[ID.COMPILE] = { m_run.compile },
-- Tools -> Snippets
[ID.INSERT_SNIPPET] = { m_snippets.insert },
diff --git a/modules/textadept/run.lua b/modules/textadept/run.lua
index f6d75ff0..d6fa0a24 100644
--- a/modules/textadept/run.lua
+++ b/modules/textadept/run.lua
@@ -36,33 +36,34 @@ function execute(command)
end
---
--- [Local table] File extensions and their associated 'compile' actions.
+-- File extensions and their associated 'compile' actions.
-- Each key is a file extension whose value is a either a command line string to
-- execute or a function returning one.
-- @class table
--- @name compile_for_ext
-local compile_for_ext = {
+-- @name compile_commands
+compile_commands = {
c = 'gcc -pedantic -Os -o "%(filename_noext)" %(filename)',
cpp = 'g++ -pedantic -Os -o "%(filename_noext)" %(filename)',
java = 'javac "%(filename)"'
}
---
--- Compiles the file as specified by its extension in the compile_for_ext table.
--- @see compile_for_ext
+-- Compiles the file as specified by its extension in the compile_commands
+-- table.
+-- @see compile_commands
function compile()
if not buffer.filename then return end
- local action = compile_for_ext[buffer.filename:match('[^.]+$')]
+ local action = compile_commands[buffer.filename:match('[^.]+$')]
if action then execute(type(action) == 'function' and action() or action) end
end
---
--- [Local table] File extensions and their associated 'go' actions.
+-- File extensions and their associated 'go' actions.
-- Each key is a file extension whose value is either a command line string to
-- execute or a function returning one.
-- @class table
--- @name go_for_ext
-local go_for_ext = {
+-- @name run_commands
+run_commands = {
c = '%(filedir)%(filename_noext)',
cpp = '%(filedir)%(filename_noext)',
java = function()
@@ -89,11 +90,12 @@ local go_for_ext = {
}
---
--- Runs/executes the file as specified by its extension in the go_for_ext table.
--- @see go_for_ext
-function go()
+-- Runs/executes the file as specified by its extension in the run_commands
+-- table.
+-- @see run_commands
+function run()
if not buffer.filename then return end
- local action = go_for_ext[buffer.filename:match('[^.]+$')]
+ local action = run_commands[buffer.filename:match('[^.]+$')]
if action then execute(type(action) == 'function' and action() or action) end
end