[Geany] GeanyLua plug-in "prefix" key?

Jeff Pohlmeyer yetanothergeek at xxxxx
Wed Jan 23 09:32:16 UTC 2008


On Jan 23, 2008 12:05 AM, John Gabriele <jmg3000 at gmail.com> wrote:

> Sweet! Thanks Jeff.
You're welcome!


> Works nicely for me, though I had to use full paths to
> name the scripts that get activated

Yes, that was just a quick-and-dirty example to give a
general idea of how it works. Actually, the "if-then-elseif"
construct could get rather unwieldy (and ugly) when you
start to add a lot of keys. A more elegant solution would
be to use a lookup table:


-------------

local keytable = {
  l = "examples/edit/lua-replace.lua",
  p = "examples/edit/proper-case.lua",
  r = "examples/edit/reverse.lua",
  t = "examples/edit/right-trim.lua",
  b = "examples/edit/select-block.lua"
}

local key = geany.keygrab()

if key then
  local filename=keytable[key]
  if filename then
    dofile(geany.appinfo().scriptdir.."/"..filename)
  else
    geany.message("Key value '"..key.."' not assigned.")
  end
end

-------------

> (I put some notes on it in the Plug-ins section of my
> tiny online Geany notes:
> http://www.milliwatt-software.com/jmg/notes/geany.html ).


Thanks for the kind words,
 - Jeff



More information about the Users mailing list