I'm trying to write a query command that will complete on a list of
files in a particular directory (a muse-el project), minus the
extensions. To do this, I'm using ioncore.popen_bgread to run ls and
call a function to massage the output and do the query once the ls has
been run.
For some reason the function (query_list, below) is being called twice,
once with str set to reasonable ls output, the second time set to nil.
Then if I hit tab, I get this in ion's output:
ion3: mod_query.lua:356: bad argument #1 to `len' (string expected, got
userdata)
ion3: Stack trace:
0 [C]: in 'complete'
1 [string "return function(_, _sub) return (WEdln.comp..."]:1
[Skipping unnamed C functions.]
Any ideas?
I'm using the ion3-20060107-4 debian package. Here's the code in
question:
function query_muse(mplex, project, projectdir)
local function handler(m, file)
app.emacs_eval("(muse-project-find-file \""..file.."\"
\""..project.."\")")
end
local function query_list(str)
local list = {}
if str then
for val in string.gfind(str, "[^\n]+") do
local ent
ent = string.sub(val, 1, string.find(val, "%.muse$")-1)
if string.len(ent) ~= 0 then
table.insert(list, ent)
end
end
end
local function completor(s)
return mod_query.complete_name(s, list)
end
mod_query.query(mplex, project..": ", "",
handler, completor)
end
ioncore.popen_bgread("/bin/ls "..projectdir.."/*.muse", query_list)
end
--
Jeremy Hankins <[EMAIL PROTECTED]>
PGP fingerprint: 748F 4D16 538E 75D6 8333 9E10 D212 B5ED 37D0 0A03