From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6556 invoked from network); 15 Jul 2003 18:35:57 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 15 Jul 2003 18:35:57 -0000 Received: (qmail 9907 invoked by alias); 15 Jul 2003 18:35:51 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 18859 Received: (qmail 9898 invoked from network); 15 Jul 2003 18:35:50 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 15 Jul 2003 18:35:50 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [62.189.183.235] by sunsite.dk (MessageWall 1.0.8) with SMTP; 15 Jul 2003 18:35:50 -0000 Received: from EXCHANGE02.csr.com (unverified) by MAILSWEEPER01.cambridgesiliconradio.com (Content Technologies SMTPRS 4.3.10) with ESMTP id for ; Mon, 14 Jul 2003 19:35:15 +0100 Received: from csr.com ([192.168.144.127]) by EXCHANGE02.csr.com with Microsoft SMTPSVC(5.0.2195.5329); Tue, 15 Jul 2003 19:34:42 +0100 To: zsh-workers@sunsite.dk Subject: Re: Preventing sorting in completers In-reply-to: "Bart Schaefer"'s message of "Tue, 15 Jul 2003 16:16:32 -0000." <1030715161632.ZM7795@candle.brasslantern.com> Date: Tue, 15 Jul 2003 19:35:47 +0100 Message-ID: <14937.1058294147@csr.com> From: Peter Stephenson X-OriginalArrivalTime: 15 Jul 2003 18:34:42.0042 (UTC) FILETIME=[C18635A0:01C34AFF] 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 -- Peter Stephenson Software Engineer CSR Ltd., Science Park, Milton Road, Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070 ********************************************************************** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. **********************************************************************