From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27236 invoked by alias); 25 Feb 2014 14:34:29 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18512 Received: (qmail 25012 invoked from network); 25 Feb 2014 14:34:13 -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=-0.7 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_NUMERIC_HELO,SPF_HELO_PASS autolearn=no version=3.3.2 X-Injected-Via-Gmane: http://gmane.org/ To: zsh-users@zsh.org From: Yuri D'Elia Subject: Re: widget special PREFIX variable and cursor position with complete_in_word Date: Tue, 25 Feb 2014 15:33:58 +0100 Message-ID: References: <140212214707.ZM25929@torch.brasslantern.com> <140213092531.ZM26966@torch.brasslantern.com> <140213223438.ZM27375@torch.brasslantern.com> <13128.1392379014@thecus.kiddle.eu> <13979.1392388765@thecus.kiddle.eu> <15748.1392413785@thecus.kiddle.eu> <12657.1392655814@thecus.kiddle.eu> <16810.1392737023@thecus.kiddle.eu> <19322.1392746842@thecus.kiddle.eu> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 193.106.183.18 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.3.0 In-Reply-To: On 02/25/2014 03:07 PM, Jesper Nygårds wrote: > Yuri, Oliver, > > This thread has been very interesting, but also a bit hard to follow. Would > any one of you care to share the final version of your solution, in a more > concise form? The functionality seems very useful to me. My current setup: [zshrc] fpath+=( $ZDOTDIR/.zfunc ) zmodload zsh/complist compinit -u zstyle ':completion:*' completer _show_ambiguity _complete [$ZDOTDIR/.zfunc/_show_ambiguity] #autoload _show_ambiguity() { (( $comppostfuncs[(I)_show_ambiguity_end] )) || comppostfuncs+=( _show_ambiguity_end ) return 1 } _show_ambiguity_end() { local prefix=${${compstate[unambiguous]}[1,${compstate[unambiguous_cursor]}-1]} local unesc=' \''"' [ -n "$prefix" ] && ZLS_COLORS+=":=${prefix[1,-2]//?/(}${prefix[1,-2]//(#m)?/${${MATCH:q}//\\[$unesc]/$MATCH}|)}${${prefix[-1]:q}//\\[$unesc]/$prefix[-1]}(#b)(?|)*==4" ZLS_COLORS+=":=*=0" } _show_ambiguity "$@" EOF As an additional note, I finally decided not to highlight the first character in a full list, as Oliver said it's mostly redundant (although Emacs does it anyway). The partial match seems to work fine, and with the fixed escaping it matches all cases correctly. I also use a final ":=*=0" color spec to disable any built-in coloring rules when the ambiguity match fails (I like my completions to be colorless). To be honest, I often work with directories with large lists of files, and showing the ambiguity like emacs started to do a while ago is a godsend since I do not use menu completition.