Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions ple.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit wasted effort in case no initfile is found. Also there is some duplication on the lines below (1056, 1060, 1065).

Let me know if you prefer to also separate the locating and the loading of the initfile as in 8280237 (addresses the wasted effort and duplication).

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
Expand Down