zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: Paul Lew <lew@ezdzit.zko.dec.com>, zsh-users@math.gatech.edu
Subject: Re: compctl tips needed on words with common prefix
Date: Wed, 17 Jun 1998 11:27:24 -0700	[thread overview]
Message-ID: <980617112724.ZM712@candle.brasslantern.com> (raw)
In-Reply-To: <9806171633.AA09038@ezdzit.zko.dec.com>

On Jun 17, 12:33pm, Paul Lew wrote:
} Subject: Re: compctl tips needed on words with common prefix
}
} >>>>> "Bart" == Bart Schaefer <schaefer@brasslantern.com> 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


  reply	other threads:[~1998-06-17 18:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-06-17 15:10 Paul Lew
1998-06-17 15:34 ` Zefram
1998-06-17 16:17   ` Paul Lew
1998-06-17 16:07 ` Bart Schaefer
1998-06-17 16:33   ` Paul Lew
1998-06-17 18:27     ` Bart Schaefer [this message]
1998-06-18  2:58       ` Paul Lew

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=980617112724.ZM712@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=lew@ezdzit.zko.dec.com \
    --cc=zsh-users@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).