zsh-users
 help / color / mirror / code / Atom feed
* grouping in patterns in extended compctl
@ 1997-02-24 16:33 John Harres
  1997-02-24 20:11 ` Zefram
  0 siblings, 1 reply; 4+ messages in thread
From: John Harres @ 1997-02-24 16:33 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1939 bytes --]

I'm trying to build completion control for a rather complicated command, and
have run into a snag trying to override the default precedence in the pattern
specification for extended completion (what a sentence!).

Here's what I have so far:

dbobj=(cycle cyclev device file finss gidmap history host job license location m
ediatype osref pool poolacl rack saveacl saveset slot uidmap volacl volalias vol
ume wo woparam xgid xuid)
volparams=(volid volname ansil side flipid nxtid gid uid hostid purdate cerdate
cleandate cleancnt initdate accdate mountcnt expdate length capacity slotid onda
te nxtlocid offdate cyclevid devid casel barcode mode protection brand density n
ote locid mediatypes poolid volstate statedate cycleid cyclename cycv_seq device
 flipansil flipvolname host location mediatype nxtansil nxtlocation nxtvolname p
ool prvansil prvid prvvolname rackname rackid slotname)

compctl -k '(add delete modify query)' \
   -x 'c[-1,add][-1,delete][-1,modify][-1,query]' -k dbobj - \
   'c[-2,add][-2,delete][-2,modify][-2,query] c[-1,volume] s[-] , s[-m_]' -k volparams -- sc

Unfortunately, what need to do with the second pattern set is say:

if two words ago was one of 'add delete modify, or query', and one word ago
was 'volume' and the current word starts with - or -m_, then match with any
of the volparams array.  Unfortunately, the default precedence appears to and
the c[-1,volume] and s[-] before the or'ing of s[-] , s[-m_].  Suggestions?

Also, any suggestions on cleaning this up in general would be appreciated.
This could end up being one of the longest compctl's ever built!  Which brings
up another question:  what's the max length of one of these?

John
-- 
John Harres <harres@uwyo.edu>        http://horseman.uwyo.edu/~harres
<A HREF="http://www.uwyo.edu">University of Wyoming</A> 
Finger harres@horseman.uwyo.edu for PGP public key.
Key fingerprint =  FC B4 72 D6 37 A7 A1 73  BE 8B F3 E2 99 68 BF 5A 



[-- Attachment #2: Type: application/pgp-signature, Size: 239 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: grouping in patterns in extended compctl
  1997-02-24 16:33 grouping in patterns in extended compctl John Harres
@ 1997-02-24 20:11 ` Zefram
  1997-02-24 20:31   ` John Harres
  0 siblings, 1 reply; 4+ messages in thread
From: Zefram @ 1997-02-24 20:11 UTC (permalink / raw)
  To: John Harres; +Cc: zsh-users

John Harres wrote:
>   'c[-2,add][-2,delete][-2,modify][-2,query] c[-1,volume] s[-] , s[-m_]' -k volparams -- sc
>
>Unfortunately, what need to do with the second pattern set is say:
>
>if two words ago was one of 'add delete modify, or query', and one word ago
>was 'volume' and the current word starts with - or -m_, then match with any
>of the volparams array.  Unfortunately, the default precedence appears to and
>the c[-1,volume] and s[-] before the or'ing of s[-] , s[-m_].  Suggestions?

You could repeat the "c[-2,...] c[-1,volume]" part after the comma.

>This could end up being one of the longest compctl's ever built!

Have you looked at the gcc compctl in Misc/compctl-examples?

>                                                                  Which brings
>up another question:  what's the max length of one of these?

How much memory do you have?

-zefram


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: grouping in patterns in extended compctl
  1997-02-24 20:11 ` Zefram
@ 1997-02-24 20:31   ` John Harres
  1997-02-24 23:43     ` Zefram
  0 siblings, 1 reply; 4+ messages in thread
From: John Harres @ 1997-02-24 20:31 UTC (permalink / raw)
  To: Zefram; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1475 bytes --]

On Mon 24 Feb 97, zefram@dcs.warwick.ac.uk wrote:

> John Harres wrote:
> >   'c[-2,add][-2,delete][-2,modify][-2,query] c[-1,volume] s[-] , s[-m_]' -k
>  volparams -- sc
> >
> 
> You could repeat the "c[-2,...] c[-1,volume]" part after the comma.
After some refinement, that line is now:

   'w[1,add][1,delete][1,modify][1,query] w[2,volume] s[-] , 
w[1,add][1,delete][1,modify][1,query] w[2,volume] s[-m_]' -k volparams -

which doesn't seem to work for the -m_ stuff.  I was just hoping that there
was an easier way of handling this, since this is just the first one for the
array.

dbobj=(cycle cyclev device file finss gidmap history host job license location 
m
ediatype osref pool poolacl rack saveacl saveset slot uidmap volacl volalias 
vol
ume wo woparam xgid xuid)

> 
> >This could end up being one of the longest compctl's ever built!
> 
> Have you looked at the gcc compctl in Misc/compctl-examples?

Yes, I have, and I still stand by my statement.  This program was originally
written by some VMS people who converted it to UNIX, thus it's quite verbose
in its options.

Thanks for the help.  Any ideas why the -m_ doesn't work?  Maybe because the
previous s[-] is a prefix of [-m_] ?  Workarounds?

John
-- 
John Harres <harres@uwyo.edu>        http://horseman.uwyo.edu/~harres
<A HREF="http://www.uwyo.edu">University of Wyoming</A> 
Finger harres@horseman.uwyo.edu for PGP public key.
Key fingerprint =  FC B4 72 D6 37 A7 A1 73  BE 8B F3 E2 99 68 BF 5A 



[-- Attachment #2: Type: application/pgp-signature, Size: 239 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: grouping in patterns in extended compctl
  1997-02-24 20:31   ` John Harres
@ 1997-02-24 23:43     ` Zefram
  0 siblings, 0 replies; 4+ messages in thread
From: Zefram @ 1997-02-24 23:43 UTC (permalink / raw)
  To: John Harres; +Cc: zefram, zsh-users

John Harres wrote:
>Thanks for the help.  Any ideas why the -m_ doesn't work?  Maybe because the
>previous s[-] is a prefix of [-m_] ?  Workarounds?

Yes.  Put the -m_ one first.

-zefram


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1997-02-24 23:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-02-24 16:33 grouping in patterns in extended compctl John Harres
1997-02-24 20:11 ` Zefram
1997-02-24 20:31   ` John Harres
1997-02-24 23:43     ` Zefram

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).