aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/textadept/command_entry.lua5
1 files changed, 4 insertions, 1 deletions
diff --git a/modules/textadept/command_entry.lua b/modules/textadept/command_entry.lua
index a22b10c6..dab02e2b 100644
--- a/modules/textadept/command_entry.lua
+++ b/modules/textadept/command_entry.lua
@@ -99,12 +99,15 @@ local env = setmetatable({}, {
-- Executes string *code* as Lua code.
-- Code is subject to an "abbreviated" environment where the `buffer`, `view`,
-- and `gui` tables are also considered as globals.
+-- Print the results of '=' expressions like in the Lua prompt.
-- @param code The Lua code to execute.
-- @name execute_lua
function M.execute_lua(code)
+ if code:sub(1, 1) == '=' then code = 'return '..code:sub(2) end
local f, err = load(code, nil, 'bt', env)
if err then error(err) end
- f()
+ local result = f()
+ if result ~= nil then gui.print(result) end
events.emit(events.UPDATE_UI)
end
args.register('-e', '--execute', 1, M.execute_lua, 'Execute Lua code')