From bc48d477247c9fccfa296fa925a428572361ae63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Buckwalter?= Date: Sun, 7 May 2023 13:30:06 +0200 Subject: [PATCH] Make `editor` local. Refer to discussion in pull request #10. --- ple.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ple.lua b/ple.lua index 437149a..e0cd3b5 100644 --- a/ple.lua +++ b/ple.lua @@ -134,7 +134,7 @@ local style = core.style -- It contains variables and functions that can be used -- in ple_init.lua -- 'editor' must be global to be visible in ple_init.lua -editor = {} +local editor = {} -- dialog functions @@ -1051,17 +1051,18 @@ local function editor_loadinitfile() -- function to be executed before entering the editor loop -- could be used to load a configuration/initialization file local initfile = os.getenv("PLE_INIT") + local env = {editor = editor, table.unpack(_G)} if fileexists(initfile) then - return assert(loadfile(initfile))() + return assert(loadfile(initfile, nil, env))() end initfile = "./ple_init.lua" if fileexists(initfile) then - return assert(loadfile(initfile))() + return assert(loadfile(initfile, nil, env))() end local homedir = os.getenv("HOME") or "~" initfile = homedir .. "/.config/ple/ple_init.lua" if fileexists(initfile) then - return assert(loadfile(initfile))() + return assert(loadfile(initfile, nil, env))() end return nil end--editor_loadinitfile