From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6734 invoked from network); 22 Jul 2003 19:51:23 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 22 Jul 2003 19:51:23 -0000 Received: (qmail 28437 invoked by alias); 22 Jul 2003 19:51:17 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 18886 Received: (qmail 28425 invoked from network); 22 Jul 2003 19:51:16 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 22 Jul 2003 19:51:16 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [216.27.190.146] by sunsite.dk (MessageWall 1.0.8) with SMTP; 22 Jul 2003 19:51:15 -0000 Received: from ceramic.fifi.org (mail@ceramic.fifi.org [216.27.190.147]) by tantale.fifi.org (8.9.3p2/8.9.3/Debian 8.9.3-21) with ESMTP id MAA06221; Tue, 22 Jul 2003 12:51:10 -0700 Received: from phil by ceramic.fifi.org with local (Exim 3.35 #1 (Debian)) id 19f3AD-0006iI-00; Tue, 22 Jul 2003 12:51:09 -0700 To: Peter Stephenson Cc: zsh-workers@sunsite.dk Subject: Re: Preventing sorting in completers References: <14937.1058294147@csr.com> Mail-Copies-To: nobody From: Philippe Troin Date: 22 Jul 2003 12:51:09 -0700 In-Reply-To: <14937.1058294147@csr.com> Message-ID: <87oezm5oia.fsf@ceramic.fifi.org> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: Philippe Troin Any reason why this has not made it into cvs as of July 22 2003? Phil. Peter Stephenson writes: > Bart Schaefer wrote: > > Slightly revised suggestion: Allow styles to override an explicit -J, > > but do not allow overriding an explicit -V. I did a quick grep, and > > there are very few cases where the -V option is passed; but in none of > > those would it be useful to apply a sort. > > I've now ended up with the following. The special history code is still > necessary because it reverses the usual default; it assumes you don't > want it sorted unless you say you do. > > Index: Completion/Base/Core/_description > =================================================================== > RCS file: /cvsroot/zsh/zsh/Completion/Base/Core/_description,v > retrieving revision 1.4 > diff -u -r1.4 _description > --- Completion/Base/Core/_description 12 Feb 2002 13:37:03 -0000 1.4 > +++ Completion/Base/Core/_description 15 Jul 2003 18:32:02 -0000 > @@ -1,6 +1,6 @@ > #autoload > > -local name gropt nopt xopt format gname hidden hide match opts tag > +local name gropt nopt xopt format gname hidden hide match opts tag sort > > opts=() > > @@ -30,6 +30,18 @@ > zstyle -s ":completion:${curcontext}:$1" matcher match && > opts=($opts -M "$match") > [[ -n "$_matcher" ]] && opts=($opts -M "$_matcher") > + > +# Use sort style, but ignore `menu' value to help _expand. > +# Also don't override explicit use of -V. > +if { zstyle -s ":completion:${curcontext}:$1" sort sort || > + zstyle -s ":completion:${curcontext}:" sort sort; } && > + [[ "$gropt" = -J && $sort != menu ]]; then > + if [[ "$sort" = (yes|true|1|on) ]]; then > + gropt=(-J) > + else > + gropt=(-V) > + fi > +fi > > if [[ -z "$_comp_no_ignore" ]]; then > zstyle -a ":completion:${curcontext}:$1" ignored-patterns _comp_ignore || > Index: Doc/Zsh/compsys.yo > =================================================================== > RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v > retrieving revision 1.171 > diff -u -r1.171 compsys.yo > --- Doc/Zsh/compsys.yo 7 Jul 2003 09:48:46 -0000 1.171 > +++ Doc/Zsh/compsys.yo 15 Jul 2003 18:32:02 -0000 > @@ -2162,12 +2162,22 @@ > ) > kindex(sort, completion style) > item(tt(sort))( > -If set to `true', completing words from the command > -history sorts the words alphabetically instead of > -keeping them in the order in which they appear in the history (from > -youngest to oldest). > +Many completion widgets call tt(_description) at some point which > +decides whether the matches are added sorted or unsorted (often > +indirectly via tt(_wanted) or tt(_requested)). This style can be set > +explicitly to one of the usual true or false values as an override. > +If it is not set for the context, the standard behaviour of the > +calling widget is used. > > -This is also used by the tt(_expand) completer. If it is set to > +The style is tested first against the full context including the tag, and > +if that fails to produce a value against the context without the tag. > + > +If the calling widget explicitly requests unsorted matches, this is usually > +honoured. However, the default (unsorted) behaviour of completion > +for the command history may be overridden by setting the style to > +tt(true). > + > +In the tt(_expand) completer, if it is set to > `true', the expansions generated will always be sorted. If it is set > to `tt(menu)', then the expansions are only sorted when they are offered > as single strings but not in the string containing all possible