2006/1/26, Philip Ganchev <[EMAIL PROTECTED]>: > On 1/25/06, Axel Liljencrantz <[EMAIL PROTECTED]> wrote: > > 2006/1/25, Philip Ganchev <[EMAIL PROTECTED]>: > [...] > > > Perhaps `complete' could be extended to allow specifying that a > > > command takes a command as an argument? A more general mechanism > > > might allow specifying a command to run to check for valid > > > completions. > > > > Right now, I'm thinking that an idea proposed long ago by Netocrat > > might be the right thing to solve this: One could move the completion > > handler into shellscript. If e.g. 'complete --do-complete "ls --col"' > > would return all possible completions for 'ls --col' one could > > arbtrarily nest completions. This would open up a huge amount of > > possibilities. > > I don't understand this, and I couldn't find Netocrat's mail in the > list archive. The suggestion is to re-implement the builtin > `complete' as a fish script? It would be much slower. Can't the same > mechanism be implemented as a builtin?
No, nothing that drastic. 'complete' would remain a builtin. I think what I mean is best described by showing what happens when a user presses <tab> now and in my proposed new version: <tab> is pressed The keybinding library maps the <tab> character to the internal R_COMPLETE binding The fish reader library is notified that the R_COMPLETE binding was triggered The fish reader library tells the completion library to calculate a listing of all the completions for the current commandline The listing is calculated and returned by the completion library The reader library either completed the commandline or starts the fish_pager command to show the completions The new version: <tab> is pressed The keybinding library maps the <tab> character to the shellscript function __fish_handle_completion The shellscript function __fish_handle_completion calls the 'complete' asking it to find the completions for the current commandline The listing is calculated and returned by the completion library The shellscript function __fish_handle_completion either completed the commandline or starts the fish_pager command to show the completions As you can see, this means that only the 'coordinator role', currently handled by the reader library, is taken over by a shellscript. The amount of code removed is small, maybe a few hundred lines of code. > > I presume the list of valid completions for 'ls --col' would not be > defined explicitly? > They would be returned as output in a format suitable both for human readability and machine parsing. -- Axel -- Axel
