From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1213 invoked from network); 17 Jun 1998 18:32:27 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 17 Jun 1998 18:32:27 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id OAA00733; Wed, 17 Jun 1998 14:27:35 -0400 (EDT) Resent-Date: Wed, 17 Jun 1998 14:27:13 -0400 (EDT) From: "Bart Schaefer" Message-Id: <980617112724.ZM712@candle.brasslantern.com> Date: Wed, 17 Jun 1998 11:27:24 -0700 In-Reply-To: <9806171633.AA09038@ezdzit.zko.dec.com> Comments: In reply to Paul Lew "Re: compctl tips needed on words with common prefix" (Jun 17, 12:33pm) References: <9806171510.AA08785@ezdzit.zko.dec.com> <980617090730.ZM15226@candle.brasslantern.com> <9806171633.AA09038@ezdzit.zko.dec.com> X-Mailer: Z-Mail (4.0b.820 20aug96) To: Paul Lew , zsh-users@math.gatech.edu Subject: Re: compctl tips needed on words with common prefix MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"khQhO.0.oA._f0Yr"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1629 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Jun 17, 12:33pm, Paul Lew wrote: } Subject: Re: compctl tips needed on words with common prefix } } >>>>> "Bart" == Bart Schaefer writes: } } Bart> What you mean to say, I think, is that any of (co1 co2 co3) } Bart> may appear *after* "co ". Right? In that case, what you } Bart> want is "c[-1,co]": } } Bart> compctl -k "(ci co construct cinema)" \ } Bart> -x "c[-1,co]" -k "(co1 co2 co3)" \ } Bart> - "c[-1,construct]" -k "(cons1 cons2)" -- xxx } } That works. But my situation is a little different, what I would like } is to have "co1 co2 co3" be part of the completion words as long as } there is a word "co" in front, i.e., } } xxx co co1 co2 or } xxx co co3 co1 co2 } } Do c[offset,string] require a fixed offset or can be a range? Yes, the offset must be fixed for c[]. } Also, I still want to be able to complete the 'construct'. Your best bet might be to go with compctl -K and write yourself a function to perform the pattern matching. The built-in mechanisms aren't designed to deal easily with so many words with common prefixes. (If your command looked like "xxx -co co1 co2 -construct cons1" then it'd be much easier.) Here's a sample that illustrates two possible approaches to your problem that don't use a -K function: compctl -k "(ci co construct cinema)" \ -x "c[-1,co]" -k "(co1 co2 co3)" \ - "C[-1,co[123]]" -k "(co1 co2 co3 construct)" \ - "c[-1,construct], C[-1,cons[12]]" -k "(cons1 cons2)" -- xxx The first approach is to use separate rules "c[-1,co]" and "C[-1,co[123]]" which tell what to complete after a word matching "co" and after a word matching the glob pattern "co[123]", respectively. This requires that you maintain the (co1 co2 co3) list in two places, and also keep the glob up to date, if those items in the -k list ever change. The second uses alternative patterns "c[-1,construct], C[-1,cons[12]]" which match either "construct" or the glob "cons[12]". This is a bit simpler to maintain (one list and the equivalent glob) but does not permit you e.g. to complete "co" following "cons1". Good luck. (I hesitate to inquire further about the "xxx cinema" part ...) -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com