Actually I was playing with FFI callbacks and readline just last week end, I've managed to integrate [1] in pure Lua and making a pretty configurable shell (it is possible to add custom completers, change prompt dynamically, ...). It's not a patch but a standalone Lua script and the code still needs some cleanup but I can upload it somewhere if you want.
[1]
https://github.com/rrthomas/lua-rlcompleter