While I like that ion supports completion in the query box, it seems to me that a
feature like Vim's "wildmenu" might be nice where repeated tabbing scrolls through the
options. While it might be inconsistent with normal command line usage, it would be
helpful when there are many options to consider, and it's definitely more useful when
doing substring matches:
function querylib.complete_pls(str)
songs = {}
for ln in io.lines("$HOME/.xmms/xmms.m3u") do
local song2;
local song, count =string.gsub(ln, "^/.*/([^/]-).mp3$", "%1")
if count > 0 then
table.insert(songs, "\""..song.."\"")
end
song2, count =string.gsub(ln, "^#EXTINF:%d+,(.*)$", "%1")
if count > 0 and song2 ~= song then
table.insert(songs, "\""..song2.."\"")
end
end
if string.len(str)==0 then
return songs
end
local res={}
str = string.lower(str)
for _, v in ipairs(songs) do
local s, e=string.find(string.lower(v), str, 1, true)
if s and e then
table.insert(res, v)
end
end
return res
end
This gives me a list of all the songs in my xmms playlist, and I use a version of
xmmsctrl I modified for the purpose of getting xmms to jump to a song with whatever
matches what is typed in using a /substring/ match. Substring is a much better way to
search for titles. The problem is that if you do this with a substring matching
multiple entries, the current ion complete logic leaves on the command line only the
part that matches all completions, (which with the above code is the " character.
(Note that I'm forcing the "'s into the entry because my modded xmmsctrl expects there
to be just one argument for the jump command. Even so, without that it would clear
the line.)
While another solution might be leaving what the user typed on the line for further
completions, this wouldn't help in cases where it's the beginning of the matches that
are different:
123456
23456
user types: 456
Here if 123456 became selected and a second tab press moved the selection to 23456,
life would be much easier.
I thought about using the menu plugin instead, but then there is no substring matching
at all, and I'm not sure how it handles there being too many items for the screen (I
never tried, but the query module has scrolling support).
Thoughts?
--Kevin