zsh-users
 help / color / mirror / code / Atom feed
* Help w/compctl & ksh_glob
@ 2003-08-16  6:59 Jerry A!
  2003-08-16 16:08 ` Oliver Kiddle
  2003-08-16 17:07 ` Bart Schaefer
  0 siblings, 2 replies; 5+ messages in thread
From: Jerry A! @ 2003-08-16  6:59 UTC (permalink / raw)
  To: zsh-users

I'm trying to setup some simple completions under zsh 4.0.6 using
'compctl' and 'emulate ksh'.  Nothing fancy, just matching programs to
extensions.  For example:

compctl -/g '*.+(b{oo,ar,az}|quu|txt)' foo

This ends up not working, nothing gets expanded.  I've tried replacing
'-/g' with '-/s'.  This works a little better.  It'll match the
appropriate files in the current directory.  It'll even complete
directory names.  However, it won't complete file matches in a given
directory.  For instance:

foo[TAB] will show 'x.bar' and 'subdir/'
foo x[TAB] will complete 'x.bar'
foo sub[TAB] will complete 'subdir/'

Now if 'subdir/y.baz' exists, the following will not work:

foo 'subdir/[TAB]' will complete 'subdir/' but will not show any
viable matches under 'subdir/'.

I feel like I'm missing something obvious.  Any pointers or help would
be greatly appreciated.

Thanks in advance...

        --Jerry            

-- 
Open-Source software isn't a matter of life or death...
...It's much more important than that!


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

* Re: Help w/compctl & ksh_glob
  2003-08-16  6:59 Help w/compctl & ksh_glob Jerry A!
@ 2003-08-16 16:08 ` Oliver Kiddle
  2003-08-16 17:07 ` Bart Schaefer
  1 sibling, 0 replies; 5+ messages in thread
From: Oliver Kiddle @ 2003-08-16 16:08 UTC (permalink / raw)
  To: Jerry A!; +Cc: zsh-users

Jerry A! wrote:
> I'm trying to setup some simple completions under zsh 4.0.6 using
> 'compctl' and 'emulate ksh'.  Nothing fancy, just matching programs to
> extensions.  For example:
> 
> compctl -/g '*.+(b{oo,ar,az}|quu|txt)' foo
> 
> This ends up not working, nothing gets expanded.  I've tried replacing

Your problem is with your attempted use of a brace expansion. Brace
expansions are a different thing from filename generation. They are
just expanded instead of matched against existing files. Try this
instead:

compctl -/g '*.+(b@(oo|ar|az)|quu|txt)' foo

Oliver


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

* Re: Help w/compctl & ksh_glob
  2003-08-16  6:59 Help w/compctl & ksh_glob Jerry A!
  2003-08-16 16:08 ` Oliver Kiddle
@ 2003-08-16 17:07 ` Bart Schaefer
  2003-08-18  6:02   ` Jerry A!
  1 sibling, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2003-08-16 17:07 UTC (permalink / raw)
  To: zsh-users

On Aug 16,  2:59am, Jerry A! wrote:
} Subject: Help w/compctl & ksh_glob
}
} I'm trying to setup some simple completions under zsh 4.0.6 using
} 'compctl' and 'emulate ksh'.

Any particular reason you're not using compinit?

} compctl -/g '*.+(b{oo,ar,az}|quu|txt)' foo
                    ^^^^^^^^^^
The documentation for 'compctl -g' may have part of the answer:

     [...]  More than one pattern may be
     given separated by blanks. (Note that brace expansion is _not_
     part of globbing.  Use the syntax `(either|or)' to match
     alternatives.)

(Of course you need +(oo|ar|az) with KSH_GLOB set.)

However, the real problem is something to do with the SH_GLOB option,
which is set by 'emulate ksh'.  If I 'unsetopt SH_GLOB' then even as
(incorrectly) written your compctl offers me directories and .txt files.

This SH_GLOB problem doesn't affect globbing outside of compctl as far
as I can tell.


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

* Re: Help w/compctl & ksh_glob
  2003-08-16 17:07 ` Bart Schaefer
@ 2003-08-18  6:02   ` Jerry A!
  2003-08-18 15:58     ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Jerry A! @ 2003-08-18  6:02 UTC (permalink / raw)
  To: zsh-users

On Sat, Aug 16, 2003 at 05:07:39PM +0000, Bart Schaefer wrote:
: On Aug 16,  2:59am, Jerry A! wrote:
: } Subject: Help w/compctl & ksh_glob
: }
: } I'm trying to setup some simple completions under zsh 4.0.6 using
: } 'compctl' and 'emulate ksh'.
: 
: Any particular reason you're not using compinit?

Yeah, I think that compinit is overkill for simple file extension
completion.

: } compctl -/g '*.+(b{oo,ar,az}|quu|txt)' foo
:                     ^^^^^^^^^^
: The documentation for 'compctl -g' may have part of the answer:
: 
:      [...]  More than one pattern may be
:      given separated by blanks. (Note that brace expansion is _not_
:      part of globbing.  Use the syntax `(either|or)' to match
:      alternatives.)
: 
: (Of course you need +(oo|ar|az) with KSH_GLOB set.)
: 
: However, the real problem is something to do with the SH_GLOB option,
: which is set by 'emulate ksh'.  If I 'unsetopt SH_GLOB' then even as
: (incorrectly) written your compctl offers me directories and .txt files.

Actually, {} globbing is valid ksh93 syntax.  It's not valid ksh88
syntax.  But I've always pictured zsh's ksh emulation as ksh93
emulation.

: This SH_GLOB problem doesn't affect globbing outside of compctl as far
: as I can tell.

This got the wheel's turning.  Turn's out that 'emulate ksh' turns on
'SH_GLOB', which in turns disables (|) globbing.  Boo, not the expected
behavior since ksh expects these characters to enumerate shell globbing.

Turning off SH_GLOB makes everything work correctly.  Thanks for giving
me a path to track down.

        --Jerry

-- 
Open-Source software isn't a matter of life or death...
...It's much more important than that!


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

* Re: Help w/compctl & ksh_glob
  2003-08-18  6:02   ` Jerry A!
@ 2003-08-18 15:58     ` Bart Schaefer
  0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2003-08-18 15:58 UTC (permalink / raw)
  To: zsh-users

On Aug 18,  2:02am, Jerry A! wrote:
} Subject: Re: Help w/compctl & ksh_glob
}
} : The documentation for 'compctl -g' may have part of the answer:
} : 
} :      [...]  More than one pattern may be
} :      given separated by blanks. (Note that brace expansion is _not_
} :      part of globbing.  Use the syntax `(either|or)' to match
} :      alternatives.)
} 
} Actually, {} globbing is valid ksh93 syntax.  It's not valid ksh88
} syntax.  But I've always pictured zsh's ksh emulation as ksh93
} emulation.

It's valid syntax, but it's not _globbing_ syntax.  The meaning of
	*.+(b{oo,ar,az}|quu|txt)
is to expand the expression to the three words
	*.+(boo|quu|txt) *.+(bar|quu|txt) *.+(baz|quu|txt)
Only _after_ that expansion has occured does globbing apply.

You can see why that must be the case if you consider an expression
	*.+(b{oo,a/r,/az}|quu|txt)
which probably results in two invalid glob patterns (it does in zsh,
at least, because alternatives within (|) can't cross directories), but
one pattern which still produces matches.  If brace expansion were part
of globbing, the entire expression would be invalid.

In the case of 'compctl -g', globbing is applied directly to the string
without first performing brace expansion, so you must use an additional
layer of (|).

} : However, the real problem is something to do with the SH_GLOB option,
} 
} This got the wheel's turning.  Turn's out that 'emulate ksh' turns on
} 'SH_GLOB', which in turns disables (|) globbing.

That's not precisely what's happening, because as I said the (|) pattern
works as expected when it's used on the command line (or at least, it
does for me); it fails only in the compctl arguments.  I haven't been
able to figure out why yet.


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

end of thread, other threads:[~2003-08-18 15:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-16  6:59 Help w/compctl & ksh_glob Jerry A!
2003-08-16 16:08 ` Oliver Kiddle
2003-08-16 17:07 ` Bart Schaefer
2003-08-18  6:02   ` Jerry A!
2003-08-18 15:58     ` Bart Schaefer

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