As a side note, it also stores each path in a table rather than as one long
string. This way they don't have to be re-split everytime a plugin is loaded.
---
core/wmii.lua | 26 +++++++++++++++++++-------
1 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/core/wmii.lua b/core/wmii.lua
index ef5bb1d..a295f0e 100644
--- a/core/wmii.lua
+++ b/core/wmii.lua
@@ -143,12 +143,24 @@ local prog_hist = history.new (20)
local action_hist = history.new(10)
-- where to find plugins
-plugin_path = os.getenv("HOME") .. "/.wmii-lua/plugins/?.so;"
- .. os.getenv("HOME") .. "/.wmii-lua/plugins/?.lua;"
- .. "/usr/local/lib/lua/5.1/wmii/?.so;"
- .. "/usr/local/share/lua/5.1/wmii/?.lua;"
- .. "/usr/lib/lua/5.1/wmii/?.so;"
- .. "/usr/share/lua/5.1/wmii/?.lua"
+plugin_paths = {}
+
+table.insert(plugin_paths, os.getenv("HOME") .. "/.wmii-lua/plugins/?.so")
+table.insert(plugin_paths, os.getenv("HOME") .. "/.wmii-lua/plugins/?.lua")
+
+for path in string.gmatch(package.path, "[^;]+") do
+ if not path:find("^./") and not path:find("core") and not path:find("plugins") then
+ local path = path:gsub("%?", "wmii/?")
+ table.insert(plugin_paths, path)
+ end
+end
+
+for path in string.gmatch(package.cpath, "[^;]+") do
+ if not path:find("^./") and not path:find("core") and not path:find("plugins") and not path:find("loadall.so") then
+ local path = path:gsub("%?", "wmii/?")
+ table.insert(plugin_paths, path)
+ end
+end
-- where to find wmiirc (see find_wmiirc())
wmiirc_path = os.getenv("HOME") .. "/.wmii-lua/wmiirc.lua;"
@@ -1681,7 +1693,7 @@ function load_plugin(name, vars)
-- first find the plugin file
local s, path_match, full_name, file
- for s in string.gmatch(plugin_path, "[^;]+") do
+ for i,s in pairs(plugin_paths) do
-- try to locate the files locally
local fn = s:gsub("%?", name)
file = io.open(fn, "r")
--
1.5.5.1
Do you use 'make install-user' ?
Since it installs everything in $HOME_WMII (.wmii-3.5, or now .wmii-lua)
I don't see how that would fail.
However, I do like the change since it's more future proof wrt the
version of the lua installed. Hard coding is inherently bad, thanks for
fixing the code.
> As a side note, it also stores each path in a table rather than as one long
> string. This way they don't have to be re-split everytime a plugin is loaded.
That's great -- I like it. Since you're on a roll, could you check if
you can share this path with the wmiirc ?
Maybe instead of:
> +plugin_paths = {}
do something like this before the module() line:
local plugin_paths = plugin_paths
and then after it do:
plugin_paths = plugin_paths ? plugin_paths : {}
Next...
> +for path in string.gmatch(package.path, "[^;]+") do
> + if not path:find("^./") and not path:find("core") and not path:find("plugins") then
It's not outside the realm of possibility to have 'core' or 'plugins' in
the path name leading up to the lua library location.
Maybe the check could be for the presence of a wmii directory in the
filesystem since that's what you're adding to the plugin_paths, how
about:
for path in string.gmatch(package.path, "[^;]+") do
local wmiidir = path:gsub("%?.*$", "wmii")
local stat = posix.stat(wmiidir)
if stat and stat.type == "directory" then
local path = path:gsub("%?", "wmii/?")
table.insert(plugin_paths, path)
end
end
The above is untested, but should be close to something workable :)
Cheers,
-Bart
--
WebSig: http://www.jukie.net/~bart/sig/