zsh-workers
 help / color / mirror / code / Atom feed
* Re: ignored-patterns giving correction a go
@ 2000-03-21 10:00 Sven Wischnowsky
  2000-03-21 16:01 ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Sven Wischnowsky @ 2000-03-21 10:00 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> ...
> 
> The only issue I have with this is that it increases the number of
> similar zstyle commands one must give to configure a behavior.  Here's
> your example from 10134:
> 
> }   zstyle ... tag-order foo=files bar=files
> }   zstyle '...:foo' file-patterns '*.ps'
> 
> Presumably the '...' part in both of those lines is, in many cases,
> going to be the same.  And then you need to repeat it _again_ to give
> the patterns for `bar'.  I find myself wishing for some way to merge
> them, maybe something like
> 
>     zstyle ... tag-order foo=files bar=files \
> 	    + foo file-patterns '*.ps' \
> 	    + bar file-patterns '*.pdf'
> 
> That specific example would make the word `+' magic, which might not be
> a good idea ... but we're running out of metacharacters that don't need
> to be annoyingly quoted.

Just occured to me: people don't need to repeat the patterns, of
course, as long as they use their own little naming convention for the 
tags they invent:

  zstyle ... tag-order --foo=files --bar=files
  zstyle '*-foo' ignored-patterns '*.ps'

Or maybe ':completion:*:-foo' or something like that. Onewould only
have to make sure that either

- these tag names are not used more than once,
- or (better) they are used consistently wherever one wants the
  behaviour configured for the tag (avoiding multiple tags with the
  same styles set for them)

Anyway, I'll first get the other stuff done and then we can discuss
(and play with) ways to make the style setup easier.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: ignored-patterns giving correction a go
@ 2000-03-22 13:32 Sven Wischnowsky
  0 siblings, 0 replies; 8+ messages in thread
From: Sven Wischnowsky @ 2000-03-22 13:32 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On Mar 21,  5:10pm, Sven Wischnowsky wrote:
> } Subject: Re: ignored-patterns giving correction a go
> }
> } > }   zstyle ... tag-order --foo=files --bar=files
> } > }   zstyle '*-foo' ignored-patterns '*.ps'
> } > 
> } > Tags right now are pretty much predetermined by the completion functions
> } > that use them, e.g. the way _files uses globbed-files.  Hmm ... is that
> } > changed by what you're working on now?
> } 
> } Yes, and that's what the original example above was about -- the
> } `user' `invented' the tag names `foo' and `bar', linking them to the
> } `method' `files'. And before that I made the suggestion to allow the
> } file-patterns style to contain invented tag names.
> 
> So where do the method names come from?  I don't think we want this to
> be so configurable that, for example, the file-patterns style could be
> caused to generate parameter names.  Do we?

Should be answered by the message I just sent...

> } > 		    shift "i > $# ? $# : i"  # Stupid shift error on i > $#
> } 
> } Yes! It's annoying, isn't it? I was tempted more than one to change it.
> 
> Bash gives the same error.  Sigh.

So does ksh (`shift: bad number'). Damn. Does that make `argv=( $argv[2,-1] )'
more efficient in some cases? (Assignments are one of those things
that get optimised by the execution code, avoiding the call to
execpline*() and execcmd().)

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: ignored-patterns giving correction a go
@ 2000-03-21 16:10 Sven Wischnowsky
  2000-03-21 16:46 ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Sven Wischnowsky @ 2000-03-21 16:10 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On Mar 21, 11:00am, Sven Wischnowsky wrote:
> } Subject: Re: ignored-patterns giving correction a go
> }
> } Bart Schaefer wrote:
> } 
> } > }   zstyle ... tag-order foo=files bar=files
> } > }   zstyle '...:foo' file-patterns '*.ps'
> } > 
> } > Presumably the '...' part in both of those lines is, in many cases,
> } > going to be the same.  And then you need to repeat it _again_ to give
> } > the patterns for `bar'.
> } 
> } Just occured to me: people don't need to repeat the patterns, of
> } course, as long as they use their own little naming convention for the 
> } tags they invent:
> } 
> }   zstyle ... tag-order --foo=files --bar=files
> }   zstyle '*-foo' ignored-patterns '*.ps'
> 
> But people arent' going to invent their own tags all that often, are they?
> Tags right now are pretty much predetermined by the completion functions
> that use them, e.g. the way _files uses globbed-files.  Hmm ... is that
> changed by what you're working on now?

Yes, and that's what the original example above was about -- the
`user' `invented' the tag names `foo' and `bar', linking them to the
`method' `files'. And before that I made the suggestion to allow the
file-patterns style to contain invented tag names.

> } > I find myself wishing for some way to merge
> } > them, maybe something like
> } > 
> } >     zstyle ... tag-order foo=files bar=files \
> } > 	    + foo file-patterns '*.ps' \
> } > 	    + bar file-patterns '*.pdf'
> } > 
> } > That specific example would make the word `+' magic, which might not be
> } > a good idea ... but we're running out of metacharacters that don't need
> } > to be annoyingly quoted.
> 
> Speaking of "just occured to me":
> 
>     function zstyle() {

I had played with the idea to first try it with a function, too ;-)

> ...
> 		    shift "i > $# ? $# : i"  # Stupid shift error on i > $#

Yes! It's annoying, isn't it? I was tempted more than one to change
it. Or maybe add an option to make it be quiet... unfortunately `shift -q' 
has always been interpreted as `shift -$q'. Sigh.


Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 8+ messages in thread
* ignored-patterns giving correction a go
@ 2000-03-16 19:03 Oliver Kiddle
  0 siblings, 0 replies; 8+ messages in thread
From: Oliver Kiddle @ 2000-03-16 19:03 UTC (permalink / raw)
  To: Zsh workers

I added the following to by .zshrc after seeing it in Peter's Zsh Guide
as an example:

zstyle ':completion:*:functions' ignored-patterns '_*'

This is often very useful because I don't get functions beginning with
underscores until I've actually typed the underscore. The trouble is
that the correction completer gets to have a go before completion is
tried without the ignored-patterns so for e.g which _co<tab> offers me
corrections such as co. Is there any way around this?

Oliver


^ permalink raw reply	[flat|nested] 8+ messages in thread
* tags and all that...
@ 2000-03-14 14:19 Sven Wischnowsky
  2000-03-17  9:05 ` ignored-patterns giving correction a go Sven Wischnowsky
  0 siblings, 1 reply; 8+ messages in thread
From: Sven Wischnowsky @ 2000-03-14 14:19 UTC (permalink / raw)
  To: zsh-workers


(So, was heisst denn `Grundsatzdiskussion' auf Englisch? ;-)


I've been thinking a lot about this file-patterns stuff we were
discussing. The biggest problem I had with the things suggested was
that there suddenly were two loops or loop-like whatevers: the tags
and the patterns. If we would make _files use only one tag, say
`files' functions like `_next_tags' would be in trouble. So I thought
about several ways how _files could be re-organised. For example we
could make the file-patterns style be inteded to be set globally,
containing tags and patterns for them. _files would then offer all
these tags or, if the style is not set, the tags it uses now with the
meaning they have now. That would use tag-order and friends as usual.

But somehow that didn't feel right. If file-patterns is needed only in 
certain contexts, one would 1) set it for those contexts and 2) set
tag-order for the same contexts, effectively repeating the tag names
and if set for a sufficiently specific context, file-patterns could
already give the ordering, as suggested by Bart. So I was back to the
beginning. Normally I try to generalise the problem in such cases (I
at least I wished I would do that always). Being able to specify ones
own patterns for files is just a special case. Similar things are
already possible with all other types of matches, for example with the 
ignored-patterns style. That made me think about tags some more.

They are kinda schizophrenic currently, aren't they? (And I'm only
talking about tags used when adding matches here...)

I mean, from a completion function's point of view, tags name `ways to
generate matches'. Nothing more. From a user's point of view, they
name a set of matches (trying to avoid the word `group' here, which is 
already used). So, if I may call the `ways to ...' `methods', then we
have the connection that completion functions know about one or
methods to generate matches and, currently, each method can generate
one set of matches. Several styles allow us to say, for example, how
the matches in the sets should be displayed (list-packed, list-colors, 
etc), which matches should not be in them (ignored-patterns) and so
on. Coming back to the _files example, we here have the case that we
have a function knowing about only one method to create matches, but
that can generate different sets of matches. And suddenly the tags
named only the sets, not the method (or the method has multiple names, 
which is equally ugly).

So I would like to first make this cleaner, by really separating
methods from sets of matches. I.e. functions would not call _tags to
say which sets they can generate, they would call, say, _methods to
say *how* they can generate matches. These methods would have
names. Users could say, which sets of matches they want, they would
have names, too. To make things a bit more confusing, let me use `tag' 
for the name of such a set. So users could say something like:

  zstyle ... tag-order foo=files bar=files

Which means that he wants to use the method `files' twice, generating
two sets of matches, named with the tags `foo' and `bar'. Then he can
use all the known styles to say, how the matches in the sets are
generated, how they are listed and so on. E.g.:

  zstyle '...:foo' file-patterns '*.ps'

Of course, we would have to add some default behaviour. And we should
try to make it look like what we have now (that's why I used those
styles in the examples). For tag-order that's relatively simple, I
think: if a value of tag-order does not contain an `=' (or whatever
token we choose):

  zstyle ... tag-order foo

it means, that `foo' is used both to name the method and the set
created. _files is probably the most complicated case: it looks at the 
options it gets (-/, -g, ...) and from that effectively builds a
default `table' mapping tags to methods and patterns (globbed-files to 
whatever was given with -g, directories to `*(-/)', all-files to `*').

But maybe we should make things more method-centered: leave tag-order
unchanged and add a new style looked up for the methods:

  zstyle '...:functions' method-tags non-comp-functions functions
  zstyle '...:non-comp-functions' ignored-patterns '_*'

So, whenever a functions offers to use the method `functions', we try
two generate two sets of matches: `non-comp-functions' and
`functions'. The tag-order style would then say in which order the
tags are tried (and we are back to having to specify tags more than
once).

On the completion function side this would of course mean that we
would have to change all places where _wanted, _tags, etc are used. In 
places where we now don't need a loop we would have to add one,
looping over the tags (sets). Where we now have a loop we would need
two nested loop, the outer one looping over the combinations of tags
and methods and the inner one looping over the methods, calling them
probably more than once, for different tags. Or the outer one looping
over the combinations and multiple inner loops looping over the
tags. That means that we can hide these tag-loops from completion
function writer by putting them into _wanted, _requested and so on
(and giveng them what is now after the `&&' as arguments which will be 
eval'ed).


Maybe I'm completely crazy now, maybe all this isn't that big a
problem to make is attempt something like this separation of methods
and tags. Two things that make me think that it may be worth it are:
Andrej (and my) question if it would be possible to have the matcher
style behave more like matcher-list. With the splitting one could
easily call a method more than once, use different tags and set the
matcher style for these tags. The second thing is my unhappiness with
all this alternate-set business. I haven't though too much about that
yet, but somehow I think there is the potential to get rid of the
alternate set altogether (leaving it only be used by compctl). That
would make me happy.


Actually, the biggest problem I see with all this is to find a good
(convenient) way to configure it. I don't like either of the ways I
showed above very much.


Opinions? Comments?


Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

end of thread, other threads:[~2000-03-22 13:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-21 10:00 ignored-patterns giving correction a go Sven Wischnowsky
2000-03-21 16:01 ` Bart Schaefer
  -- strict thread matches above, loose matches on Subject: below --
2000-03-22 13:32 Sven Wischnowsky
2000-03-21 16:10 Sven Wischnowsky
2000-03-21 16:46 ` Bart Schaefer
2000-03-16 19:03 Oliver Kiddle
2000-03-14 14:19 tags and all that Sven Wischnowsky
2000-03-17  9:05 ` ignored-patterns giving correction a go Sven Wischnowsky
2000-03-17 18:20   ` 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).