From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9042 invoked from network); 5 Oct 2001 16:11:13 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 5 Oct 2001 16:11:13 -0000 Received: (qmail 11991 invoked by alias); 5 Oct 2001 16:11:03 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 15949 Received: (qmail 11977 invoked from network); 5 Oct 2001 16:11:02 -0000 To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: PATCH: Re: expand style `suffix' option In-reply-to: "Sven Wischnowsky"'s message of "Fri, 05 Oct 2001 13:17:07 +0200." <15293.38579.803273.864907@gargle.gargle.HOWL> Date: Fri, 05 Oct 2001 17:10:23 +0100 Message-ID: <22027.1002298223@csr.com> From: Peter Stephenson Sven Wischnowsky wrote: > Right. The patch below tries to make this style work again and it > also removes the dependency on not using menu completion (that part of > the code is pretty hairy, so there might be things which now work > differently with menu-completion -- I'd like to hear about them so > that we can fix them). Working fine so far. The only glitch I've come across is that you only get the top level directory in the list even you are completing to multiple levels, e.g. ~/b/b shows up a whole load of `bin/'s in the listing. One can, of course, argue that this is perfectly reasonable: menu completion will show the full set. One could wish for an extra directory level to be shown to resolve conflicts, but then one could wish for free chocolate. Here's the compinstall stuff for the expand style. There's a glaring hole in the `styles for particular completions' in the top menu. The only entry is for file completions. I was hoping for people to add configuration for their own favourite types of completion. I haven't thought of anything that useful. Index: Completion/compinstall =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/compinstall,v retrieving revision 1.4 diff -u -r1.4 compinstall --- Completion/compinstall 2001/06/13 09:26:15 1.4 +++ Completion/compinstall 2001/10/05 15:57:42 @@ -1529,11 +1529,13 @@ # squeeze-slashes, __ci_do_file_styles() { local key files cursor expand speciald ignorep squeezes select + local prefon suffon __ci_get_this_style file-sort files __ci_get_this_style ignore-parents ignorep __ci_get_this_style special-dirs speciald __ci_get_this_style squeeze-slashes squeezes + __ci_get_this_style expand expand while true; do clear @@ -1548,6 +1550,8 @@ 4. When expanding paths, \`foo//bar' is treated as \`foo/bar'. +5. Configure how multiple paths are expanded, e.g. /f/b -> /foo/bar + q. Return without saving. 0. Done setting options for filename completion. " @@ -1655,6 +1659,52 @@ ([nN]) squeezes=;; esac ;; + (5) if [[ $expand = *prefix* ]]; then + prefon=prefix + else + prefon= + fi + if [[ $expand = *suffix* ]]; then + suffon=suffix + else + suffon= + fi + print " +When expanding /f/b, the shell will attempt to match /f*/b* (e.g. /foo/bar), +and so on to any depth. If the first part of the expansion fails, by default +the shell will not expand the remainder. However, you can force it always +to expand the first part. Currently this feature is ${${prefon:+on}:-off}. +Do you want it on ([y]es, [n]o, [k]eep current setting)? +" + while true; do + read -k key'?--- Hit selection --- ' + [[ $key = [yYnNkK] ]] && break + print "Type one of y, n or k." + done + case $key in + ([yY]) prefon=prefix;; + ([nN]) prefon=prefix;; + esac + print " +Further, if /f*/b* is ambiguous, the shell will usually only expand +as far as the part that is unambiguous; for example, if /foo/bar and +/food/basket exist, it will wait for you to choose either /foo or /food, +and not attempt to expand the rest of the match. However, you can force +it to add all possible completions for you to resolve conflicts in the +normal way. Currently this feature is ${${suffon:+on}:-off}. +Do you want it on ([y]es, [n]o, [k]eep current settign)? +" + while true; do + read -k key'?--- Hit selection --- ' + [[ $key = [yYnNkK] ]] && break + print "Type one of y, n or k." + done + case $key in + ([yY]) suffon=suffix;; + ([nN]) suffon=suffix;; + esac + expand=${prefon:+$prefon${suffon:+ }}${suffon} + ;; (q) return 1 ;; esac @@ -1665,6 +1715,7 @@ __ci_set_this_style ignore-parents ignorep __ci_set_this_style special-dirs speciald __ci_set_this_style squeeze-slashes squeezes + __ci_set_this_style expand expand return 0 } -- Peter Stephenson Software Engineer CSR Ltd., Science Park, Milton Road, Cambridge, CB4 0WH, UK Tel: +44 (0)1223 392070 ********************************************************************** 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. **********************************************************************