Norman Ramsey wrote:
>  > Actually it could be done better... attached is a 2nd patch
>  > ("ksh93_tab_tab_gmacs_completion_try2.diff.txt") which also implements
>  > TAB-TAB completion like in bash3.
>  > Single TAB now completes the filename either completely - or if that
>  > isn't possible it's completed to the point where the filenames start to
>  > differ. TAB-TAB then displays a list of choices. Additionally in "gmacs"
>  > mode typing TAB on an empty string will try to do the filename
>  > completion for the whole directory (and TAB-TAB displays all choices
>  > then). "emacs" mode still behaves as usual, incl. the ability to enter
>  > the TAB character.
> 
> I'm very interested in this patch, but because of the maintenance
> headache, I'm a bit leery of modifying the C source.  Do you have any
> idea if this one could be packaged as a loadable builtin and bound to
> the TAB key using the usual KEYBD trap?

Please try the following script:
-- snip --
emacs_completion_tab_count=0

function emacs_completion
{
    if [[ ${.sh.edchar} == "$(printf "\t")" ]] then
        emacs_completion_tab_count=$((emacs_completion_tab_count + 1))

        if [ $emacs_completion_tab_count -eq 1 ] ; then
            .sh.edchar="$(printf "\E\E")"
        elif [ $emacs_completion_tab_count -ge 2 ] ; then
            .sh.edchar="$(printf "\E=")"
        fi
    else
        emacs_completion_tab_count=0
    fi
}

trap emacs_completion KEYBD
-- snip --
The script should work almost identical to my patch.

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) roland.mainz at nrubsig.org
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 7950090
 (;O/ \/ \O;)

Reply via email to