Re: example of query completion

Nicolas Chauvat <nicolas.chauvat-yG1kfhx/[email protected]>
Newsgroups gmane.comp.window-managers.ion.general
Message-ID <[email protected]>
On Wed, Sep 10, 2008 at 08:02:17AM +0000, Tuomo Valkonen wrote:
> complete_from_list is obsolete. The current equivalent function
> prototype is
> 
>         mod_query.complete_keys(list, str, sub_ok, casei_ok)
> 
> but it is an internal undocumented function. (It completes among
> the _keys_ of 'list', not values!)

In case someone else would need the same thing, here is code that
works for me:

local simpled_verb = "simpled-verbs"

function get_possible_verbs ()
  local verbs = {}

  local f = io.popen(simpled_verb .. " --list")
  for line in f:lines() do
     verbs[line] = line 
  end
  f:close()

  return verbs
end

function query_verb(mplex)
   local possible_verbs = get_possible_verbs()
   print(possible_verbs,"\n")
   local function handler(mplex, str)
      ioncore.exec_on(mplex, simpled_verb .. ' ' .. str)
   end
   local function completor(cp, str, point)
      completions = mod_query.complete_keys(possible_verbs, str, true, true)
      cp:set_completions(completions)
   end
   mod_query.query(mplex, "verb: ", nil, handler, completor)
end


-- 
Nicolas Chauvat

logilab.fr - services en informatique scientifique et gestion de connaissances
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.