[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Advanced readline support patch added to Wiki
- From: Mike Pall <mikelu-0405@...>
- Date: Fri, 28 May 2004 04:38:54 +0200
I've added a new patch to: http://lua-users.org/wiki/LuaPowerPatches
Advanced readline support
This patch adds the following features to the existing readline support
in Lua 5.x:
* Completion of keywords and global variable names.
* Recursive and metatable-aware completion of variable names.
* Context sensitive delimiter completion.
* Save/restore of the history to/from a file (LUA_HISTORY environment
* Setting a limit for the size of the history (LUA_HISTSIZE environment
* Setting the application name to allow for $if lua ... $endif in ~/.inputrc.
After applying the patch start lua and try these (replace ~ with the TAB key):
The ~~ are just for demonstration purposes (io~s~o~w~ suffices, of course).
If you are used to zsh/tcsh-style completion support, try adding
'TAB: menu-complete' and 'C-d: possible-completions' to your ~/.inputrc.
It has been verified to work with Lua 5.0, 5.0.2, 5.1-work0 and
GNU readline 2.2.1, 4.0, 4.3 or NETBSD libedit 2.6.5, 2.6.9.
Here is the direct download link:
Please try it and see if you like it. If you have any comments, please
send them either to the list or directly to me (mikelu AT mike "(.)" de).
I'm especially interested to hear if the recursive completion works with
complex libraries that use metatables extensively. I've already tried it
with luasocket and a few others and they work just fine.
Please note that the context sensitivity has some weak spots. These are
either due to the limited lua RTTI ('.' vs. ':') or due to restrictions
in the readline library (expanding 'foo.a~' to 'foo["a b"]' does not
BTW: There is an old entry in the LuaPowerPatches section referring to
a similar patch. However the download link is broken and it's probably
outdated anyway. That's why I wrote my patch from scratch for Lua 5.x.
I assume my patch is a superset -- so I think the old entry should be
removed. Any objections?