Roland Mainz wrote: [snip] > Subject: Re: [ksh93-integration-discuss] [Bug 410] New: pressing <tab> in vi > edit mode should be similar to emacs or gmacs mode. > Date: Wed, 2 Jan 2008 09:38:35 -0500 > From: David Korn <dgk at research.att.com> > To: ksh93-integration-discuss-bounces at opensolaris.org > > > Using ksh93 in the version delivered in nv_78, I found that when using the > > "vi" > > edit mode (set -o vi) which has some unique features that [e|g]maces does > > not > > have, file name expansion by just pressing the tab key just produces a tab > > on > > the command line, even when there is just one file or directory in the > > current > > working directory. For [e|g]macs mode, pressing tab expands the > > file/directory > > name immediately, just like in bash. That's the way it should be in vi mode > > as > > well. > > vi users of ksh have always been able to use the tab key to enter a tab. > This is especially useful when entering compound commands to get commands > lined up, for example > while read -r > do ... > done > > In ksh93s+, the tab key does do completion when there is at least one > completion possible. > > However, in ksh93t, I would consider restricting tab to entering a tab > only when following a reserved word.
What about creating something like a "TAB expansion trap" (or maybe it should be named "list expansion trap" ?) which is called in such a case - the trap would get the variable name of a normal array which contains the list of strings to be presented for <tab><tab> (by default (e.g. prefilled before the trao's shell code is entered) it contains the list of filenames for this position (or variable names if the word starts with a '$'-character etc.). The trap function could then change this array (e.g. add, remove, replace entries). If the trap function completes and returns a zero exit code there are three possible options: 1. If the array is empty a <tab> charcter is inserted 2. If the array only contains one entry the string value of this array element is inserted 3. If the array contains more than one entry the shell will insert the charcters which are common for all array members. If the user enters <tab> a 2nd time the numbered list of choices is presented and <number><tab> selects the matching entry. If the trap function returns with a non-zero exit code the shell should trigger the alarm bell (e.g. $ printf "\a" #). AFAIK this way would allow all the requested kinds of customisations... right ? ----- Bye, Roland -- __ . . __ (o.\ \/ /.o) roland.mainz at nrubsig.org \__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer /O /==\ O\ TEL +49 641 7950090 (;O/ \/ \O;)