Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Custom auto complete



Hi,

The solution you posted sort of dose what I want. With this code I have to
type ?<some char(s)> in order for it to work. If I just type ? and hit tab
it dose not work.
I get that's because of  ( \?* ) and I tried (\?) but it dose not work.
Interesting, if I use for example ( \! ) that works as expected. Is the '?'
special for some reason?


Also I found another way of getting what I want I think it's a more
intuitive solution than the whole '?' idea. I found that I can write my own
widget and bind it to a key so this is what I did:

zle -C custom-complete menu-expand-or-complete _parse_sb_file

_parse_sb_file() {
WORDS=( ${(f)"$(<$SB_FILE_PATH)"} )
 ARRAY=()
integer POS=1
for ITEM in ${WORDS}; do
 ARRAY[${POS}]=${POS}") "${WORDS[${POS}]}
(( POS++ ))
        done
compadd -l -d ARRAY -a -S '' -- WORDS
}

bindkey ${CTRLTAB_KEY} custom-complete

This works but I have some issues with this to:

1) if I press ctrl-tab I can not select the options with arrow keys I can
just switch them with ctrl-tab, unless I first run for example "cp <TAB>"
then I get the menu and I can select options. And if I after that (after cp
<TAB> showed the menu with select) use ctrl-tab I get menu with select? Not
sure why I first have invoke another menu for ctrl-tab to work in a same
manner?

2) if I have this string, for example, in a file "cp file1 file2" it is
inserted like this "cp\ file1\ file2". The white spaces are escaped, how
can I disable this, and tell zsh to insert a string as it is.

Thanks for your help.

Regards,
Domagoj




On Mon, Aug 4, 2014 at 10:57 PM, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
wrote:

> On Aug 4,  1:39pm, Bart Schaefer wrote:
> }
> }       # Now anything starting with '?'
> }       (\?*) _message "Querying answerfile"
> }             compstate[insert]=menu
> }             compadd -U -a answers  # -U to replace "?" with the result
> }             ;;
>
> Hmm, it occurs to me that this should probably be in the order
>
>             compadd -U -a answers  # -U to replace "?" with the result
>             compstate[insert]=menu
>
> so that the initial value of compstate[insert] is visible to compadd
> before we change it.  I don't know exactly when that would matter, but
> the doc for compstate[insert] implies that it might.
>


Messages sorted by: Reverse Date, Date, Thread, Author