|
On 06/15/2015 10:12 PM, Coda Highland wrote:
On Mon, Jun 15, 2015 at 11:52 AM, Ross Berteig <Ross@cheshireeng.com> wrote:On 6/15/2015 10:52 AM, Coda Highland wrote:On Mon, Jun 15, 2015 at 10:38 AM, Brigham Toskin <brighamtoskin@gmail.com> wrote:- Could you do rotating tab completion instead of only to the prefix? ....Have you ever come across a program that has this behavior? I think I would find it confusing, since in my experience, ambiguous completions are usually either just given the first match it finds, or it prints a list of partial matches, prompting you to type a longer substring to specify which one you meant.I don't LIKE this behavior, but I HAVE encountered it before. It's more common in editors rather than shells -- this is the behavior of the autocomplete dropdown in many IDEs, as well as the behavior of vim's command line.It is also the file name completion behavior in Windows at the CMD.EXE prompt. I like it better than just going 'ding' because the completion is ambiguous without any other hints about what the choices are...In bash, at least, "ding" just means "hit tab again and I'll tell you what completions I know for this prefix."
Whatever the case for or against this kind of completion may be, readline tries to cater for all tastes. It supports it right out of the box, so it's available to bash and every other readline-enabled application out there.
Just add: TAB: menu-completeto you ~/.inputrc file to enable it. Of course you can also use a separate key for it, for instance
M-TAB: menu-completewill allow you to keep the default completion and use alt-tab for the variant.
Of course, these will alter the behavior of bash and everything else as well. The next version of luaprompt will allow one to apply separate configuration for luaprompt with
$if luaprompt TAB: menu-complete $endif Much more is possible of course. For more information look here http://www.gnu.org/software/bash/manual/html_node/Readline-Init-File-Syntax.html#Readline-Init-File-Syntax and here http://www.gnu.org/software/bash/manual/html_node/Bindable-Readline-Commands.html#Bindable-Readline-CommandsBy the way, it's also possible to define custom readline commands for luaprompt. These have to be implemented in C of course and I never came across a use for them, but perhaps it might be interesting to implement them in a dynamic fashion: Have a table say prompt.commands which can populated with functions which define commands. So
prompt.commands[i] = function(value) ... endwill define command luaprompt-command-i, which can be bound to any key in the same way as menu complete above. When enabled the function will be called with an argument equal to the value the cursor is on, if any. The command can the get an application-specific help-string and return it for luaprompt to print.
Of course the value can be ignored for commands that don't need it, say to bind a command to garbage collection.
Anyway, I just had this idea now, so I thought I'd mention it. It might not work out for some reason and I'm still not convinced of its utility. Let me know if you think otherwise.
D.