From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16421 invoked by alias); 6 Aug 2014 03:45:53 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 32966 Received: (qmail 22252 invoked from network); 6 Aug 2014 03:45:51 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 From: Bart Schaefer Message-id: <140805204533.ZM28316@torch.brasslantern.com> Date: Tue, 05 Aug 2014 20:45:33 -0700 In-reply-to: Comments: In reply to Domagoj Pintaric "Re: Custom auto complete" (Aug 6, 12:37am) References: <140804133941.ZM1946@torch.brasslantern.com> <140804135755.ZM2030@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Domagoj Pintaric Subject: Re: Custom auto complete Cc: zsh-workers@zsh.org MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Aug 6, 12:37am, Domagoj Pintaric wrote: } } The solution you posted sort of dose what I want. With this code I have to } type ? in order for it to work. If I just type ? and hit tab } it dose not work. Hm. I did test it. Could you post the actual function? } 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? Depends on the order of your completer style. I only tried with _query as the first one. If e.g. you have _expand in there ahead of _query, _expand will try to use the "?" on the command line as a glob pattern. You haven't really told us enough details to make a diagnosis. On the other hand you seem to prefer the custom key binding, so maybe it does not matter. } zle -C custom-complete menu-expand-or-complete _parse_sb_file Why did you chose menu-expand-or-complete here, rather than just menu-complete? When would you be using this binding for expansion? See also below ... } _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 " This is very likely because you haven't yet loaded the zsh/complist module the first time you try this, or you've loaded it but not set $MENUSELECT. When you invoke the completion system with it loads the module and sets the variable for you, and thereafter menu completion notices that $MENUSELECT has become set and enters the selection list. If you load the module yourself, you can bind to the menu-select widget and force entry into the selection list every time: zmodload zsh/complist zle -C custom-complete menu-select _parse_sb_file } 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. You need the -Q option when calling "compadd". However, note that when deciding to re-enter completion, the command line is going to be split on spaces, even if those spaces were inserted by a previous completion.