zsh-workers
 help / color / mirror / code / Atom feed
* RE: PATCH: (was Re: _configure does not work)
@ 1999-03-09 13:09 Sven Wischnowsky
  1999-03-09 13:37 ` Andrej Borsenkow
  0 siblings, 1 reply; 10+ messages in thread
From: Sven Wischnowsky @ 1999-03-09 13:09 UTC (permalink / raw)
  To: zsh-workers


Andrej Borsenkow wrote:

> > > itsrm2% ./configure --e-d<TAB>
> > > itsrm2% ./configure
> > >  (the whole stuff deleted)
> > >
> > > I'd thought, it completed to at least --enable-dynamic before.
> >
> > I think it didn't, I think it generated a list containing
> > `--enable-dynamic', `--enable-zsh-debug' and others. This was wrong in
> > the matching code in zle_tricky.c.
> >
> 
> Why? I had impression, it was the result of matcher. If I say -M 'r:|-=*
> r:|=*', then ``--e-d'' inevitably matches enable-zsh-debug. Should it not be
> handled in matcher spec? "anything except -"?

This is slightly modeled after globbing behavior: anchors of `*'
patterns separate parts like slashes separate pathname components.
Inside the word they all have to be typed explicitly.

Personally, I like this behavior much better than the `* matches even 
it's anchors' (I wanted this behavior from the beginning, so I
consider the patch to be a bug fix), because an important goal of
completion is to produce as few matches as possible -- even if this
may sound strange.

About making match specs more powerful: with the code as it is now, it 
would be easier to support a pattern for `match a couple of characters 
like ...', where the `...' is a character or character-class. However, 
implementing full support for `r:|.=[^.]#' would be very complicated,
since people would immediatly expect all the patterns they know from
globbing to be understood. The problem is that the code not only has
to do matching (that would be easy, just use the globbing code), but
also to build the strings to put in the line and in the match-structure.

So, I'll think about this some more once I have done the things I want 
to do in the matching/joining code anyway. But probably I would just
prefer a simple yse/no choice: a `*' that matches it's anchors and one 
that doesn't do that.

Of course, I'd also like to hear other people's opinion on this --
that would also give me a hint how many of you use such patterns.

Bye
 Sven

P.S.: To get the previous behavior, just de-apply the first two hunks
      of the patch to zle_tricky.c.

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


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

* RE: PATCH: (was Re: _configure does not work)
  1999-03-09 13:09 PATCH: (was Re: _configure does not work) Sven Wischnowsky
@ 1999-03-09 13:37 ` Andrej Borsenkow
  0 siblings, 0 replies; 10+ messages in thread
From: Andrej Borsenkow @ 1999-03-09 13:37 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

>
> This is slightly modeled after globbing behavior: anchors of `*'
> patterns separate parts like slashes separate pathname components.
> Inside the word they all have to be typed explicitly.
>
> Personally, I like this behavior much better than the `* matches even
> it's anchors' (I wanted this behavior from the beginning, so I
> consider the patch to be a bug fix), because an important goal of
> completion is to produce as few matches as possible -- even if this
> may sound strange.
>

Agreed. If only the manuals mentioned this as well ...

>
> So, I'll think about this some more once I have done the things I want
> to do in the matching/joining code anyway. But probably I would just
> prefer a simple yse/no choice: a `*' that matches it's anchors and one
> that doesn't do that.
>
> Of course, I'd also like to hear other people's opinion on this --
> that would also give me a hint how many of you use such patterns.
>

Well, we need some more experience. At least, this change was exactly what I
intended to ask for :-)

cheers

/andrej


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

* RE: PATCH: (was Re: _configure does not work)
  1999-03-09 14:25 Sven Wischnowsky
@ 1999-03-09 16:47 ` Andrej Borsenkow
  0 siblings, 0 replies; 10+ messages in thread
From: Andrej Borsenkow @ 1999-03-09 16:47 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

with all but a-a-m-c patches (upto 5714):

bor@itsrm2:/tools/src/zsh-3.1.5-pws-11%> ./configure --p=/to<TAB>
bor@itsrm2:/tools/src/zsh-3.1.5-pws-11%> ./configure --pr=/to
                                                         ^ cursor here
(after --pr)

   now I add `e'
bor@itsrm2:/tools/src/zsh-3.1.5-pws-11%> ./configure --pre=/to<TAB>
                                                          ^ cursor here
(after --pre)
bor@itsrm2:/tools/src/zsh-3.1.5-pws-11%> ./configure --prefix}tools/to

(I tracked actually another problem I had on Friday)

cheers

/andrej


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

* RE: PATCH: (was Re: _configure does not work)
@ 1999-03-09 14:25 Sven Wischnowsky
  1999-03-09 16:47 ` Andrej Borsenkow
  0 siblings, 1 reply; 10+ messages in thread
From: Sven Wischnowsky @ 1999-03-09 14:25 UTC (permalink / raw)
  To: zsh-workers


Andrej Borsenkow wrote:

> > > 2. l ~/.z/C<TAB>
> > >     Beep
> > > ~/.zsh.d/Completion exists and was correctly completed before a
> > couple of
> > > last patches :-)
> >
> > Hm, this works for me.
> >
> 
> That what I get with set -x:
> ...

Ah, you don't use `globcomplete'...

Bye
 Sven

diff -u oc/Core/_path_files Completion/Core/_path_files
--- oc/Core/_path_files	Tue Mar  9 15:25:02 1999
+++ Completion/Core/_path_files	Tue Mar  9 15:25:05 1999
@@ -95,6 +95,7 @@
   str="${PREFIX}*${SUFFIX}"
 else
   str="${PREFIX:q}*${SUFFIX:q}"
+  [[ "$str" = \\\~* ]] && str="$str[2,-1]"
 fi
 orig="${PREFIX}${SUFFIX}"
 

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


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

* RE: PATCH: (was Re: _configure does not work)
  1999-03-09 12:54 Sven Wischnowsky
@ 1999-03-09 14:04 ` Andrej Borsenkow
  0 siblings, 0 replies; 10+ messages in thread
From: Andrej Borsenkow @ 1999-03-09 14:04 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

>
> > 2. l ~/.z/C<TAB>
> >     Beep
> > ~/.zsh.d/Completion exists and was correctly completed before a
> couple of
> > last patches :-)
>
> Hm, this works for me.
>

That what I get with set -x:
bor@itsrm2:~%> l ~/.z/C+ local comp name _comp_correct comax
+ setopt localoptions nullglob rcexpandparam
+ unsetopt markdirs globsubst shwordsplit nounset ksharrays
+ [[ -iprefix '=' ]]
+ [[ ~/.z/C != */* ]]
+ true
+ comp=
+ [[ ! -z  ]]
+ [[ command == command ]]
+ _normal
+ local comp command cmd1 cmd2 pat val name i ret=1
+ command=ls
+ [[ CURRENT -eq 1 ]]
+ [[ l == = ]]
+ [[ ls == */* ]]
+ cmd1=ls
+ whence -p ls
+ eval cmd2=/usr/bin/ls
+ cmd2=/usr/bin/ls
+ pat=zf*
+ val=_zftp
+ [[ ls == zf* || /usr/bin/ls == zf* ]]
+ name=ls
+ comp=
+ [[ -z  ]]
+ name=/usr/bin/ls
+ comp=
+ [[ -z  ]]
+ name=-default-
+ comp=_default
+ [[ -z _default ]]
+ _default
+ compcall
+ _files
+ local nm=0 ret=1
+ _path_files
+ _match_test _path_files
+ ((  compstate[matcher] <= 1  ))
+ local nm prepaths str linepath realpath donepath patstr prepath testpath
rest
+ local tmp1 collect tmp2 suffixes i ignore matchflags opt group sopt pats
gopt
+ local addpfx addsfx expl orig ostr nm=0 menu
+ setopt localoptions nullglob rcexpandparam extendedglob
+ unsetopt markdirs globsubst shwordsplit nounset
+ prepaths=(  )
+ ignore=( )
+ group=( )
+ sopt=-
+ gopt=
+ pats=( )
+ addpfx=( )
+ addsfx=( )
+ expl=( )
+ getopts P:S:W:F:J:V:X:f/g: opt
+ [[ - == - ]]
+ [[ -z  ]]
+ sopt=-f
+ pats=( * )
+ [[ 0 -ne 0 ]]
+ str=\~/.z/C*
+ orig=~/.z/C
+ [[ unambiguous == *menu || 0 -ne 0 ]]
+ ((  ! 0  ))
+ [[ -z  ]]
+ tmp1=( )
+ nm=0
+ [[ -z  ]]
+ compgen -f
+ [[ compstate[nmatches] -eq nm ]]
+ ignore=( -F fignore )
+ [[ \ == ~ ]]
+ linepath=
+ realpath=
+ [[ \ == / ]]
+ [[ \~/.z/C* == (.|..)/* ]]
+ donepath=
+ patstr=\~/.z/C*
+ matchflags=
+ _match_pattern _path_files patstr matchflags
+ [[ -n  ]]
+ patstr=\~*/.z*/C*
+ [[ ~/.z/C == */* ]]
+ tmp1=( )
+ [[ 0 -gt 0 ]]
+ break
+ str=\~*/.z*/C*
+ testpath=
+ ostr=~/.z/C
+ [[ -z  ]]
+ [[ \~*/.z*/C* == */* ]]
+ rest=.z*/C*
+ tmp1=\~*(-/)
+ tmp1=( )
+ [[ 0 -eq 0 ]]
+ continue 2
+ [[ nm -ne compstate[nmatches] ]]
+ [[ 0 -ne 0 ]]
+ return ret
+ return ret
+ ((  0  ))
+ break
+ [[ -n  ]]
bor@itsrm2:~%> l ~/.z/C


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

* RE: PATCH: (was Re: _configure does not work)
@ 1999-03-09 13:58 Sven Wischnowsky
  0 siblings, 0 replies; 10+ messages in thread
From: Sven Wischnowsky @ 1999-03-09 13:58 UTC (permalink / raw)
  To: zsh-workers


Andrej Borsenkow wrote:

> > This is slightly modeled after globbing behavior: anchors of `*'
> > patterns separate parts like slashes separate pathname components.
> > Inside the word they all have to be typed explicitly.
> >
> > Personally, I like this behavior much better than the `* matches even
> > it's anchors' (I wanted this behavior from the beginning, so I
> > consider the patch to be a bug fix), because an important goal of
> > completion is to produce as few matches as possible -- even if this
> > may sound strange.
> >
> 
> Agreed. If only the manuals mentioned this as well ...

Yep, maybe...

Bye
 Sven

diff -u od/Zsh/compctl.yo Doc/Zsh/compctl.yo
--- od/Zsh/compctl.yo	Mon Mar  8 09:04:45 1999
+++ Doc/Zsh/compctl.yo	Tue Mar  9 14:57:08 1999
@@ -703,7 +703,8 @@
 that the pattern on the command line can match any number of characters
 in the trial completion. In this case the pattern must be anchored (on
 either side); the var(anchor) then determines how much of the trial
-completion is to be included.
+completion is to be included --- only the characters up to the next
+appearance of the anchor will be matched.
 
 Examples:
 
@@ -758,7 +759,8 @@
   -k '(comp.sources.unix comp.sources.misc ...)' ngroups))
 )
 The first specification says that tt(lpat) is the empty string, while
-tt(anchor) is a dot; tt(tpat) is tt(*), so this can match anything in
+tt(anchor) is a dot; tt(tpat) is tt(*), so this can match anything
+except for the `tt(.)' from the anchor in
 the trial completion word.  So in tt(c.s.u), the matcher sees tt(c),
 followed by the empty string, followed by the anchor `tt(.)', and
 likewise for the second dot, and replaces the empty strings before the

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


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

* RE: PATCH: (was Re: _configure does not work)
@ 1999-03-09 12:54 Sven Wischnowsky
  1999-03-09 14:04 ` Andrej Borsenkow
  0 siblings, 1 reply; 10+ messages in thread
From: Sven Wischnowsky @ 1999-03-09 12:54 UTC (permalink / raw)
  To: zsh-workers


Andrej Borsenkow wrote:

> After applying last patches (5696-5699) I get some strange results:
> 
> 1. bor@itsrm2:/tools/src/zsh-3.1.5-pws-11%> ./configure --pre<TAB>
> bor@itsrm2:/tools/src/zsh-3.1.5-pws-11%> ./configure --pre44
> fix=

Maybe I'm too tired today to fiddle with the code... this is the
output of an `echo' I had inserted for debugging.

> 2. l ~/.z/C<TAB>
>     Beep
> ~/.zsh.d/Completion exists and was correctly completed before a couple of
> last patches :-)

Hm, this works for me.

> 3. (I think, it changed recently)
> 
> ./configure --e-d<TAB>
> ./configure --enable-dynamic <^Xu> (bound to undo)
>                              ^cursor here (one blank after line)
> ./configure --enable-dynamic <^Xu>
>                              ^cursor still here
> ./configure --e-d
> 
> Well, IMHO ``--enable-dynamic '' (including blank) was inserted in _one_
> step and should be removed by _one_ command as well. And it was the case at
> least with 3-1.5-pws-10.

This is the auto-removable suffix. I faintly remember a discussion
about undoing and inserted suffixes where some people wanted to have
different `undo's for the suffix and the word. (If you don't see a auto-
removable suffix, just type a space, tab, or newline after the
`--enable-dynamic ').
So, what do (and others) think, should the first `undo' undo
everything, should this be done only if the suffix was a automatically
inserted space, should there be an option,...?

Bye
 Sven

--- oc/User/_long_options	Tue Mar  9 11:31:54 1999
+++ Completion/User/_long_options	Tue Mar  9 13:10:14 1999
@@ -89,7 +89,7 @@
 
   opts=("--${(@)^${(@)${(@)${(@M)${(@ps:\n:j:\n:)${(@)${(@M)${(@f)$("$words[1]" --help)}:#[ 	]#-*}//,/
 }}:#*--*}#*--}%%[, ]*}:#(*-[A-Z]*|)}")
-echo $#opts
+
   # The interpretation of the options is completely table driven. We
   # use the positional parameters we were given and a few standard
   # ones. Then we loop through this table.
@@ -298,7 +298,7 @@
     compadd -M 'r:|-=* r:|=*' -Q "$suffix[@]" -s "$str" - \
             "${(@P)name}" && ret=0
   elif [[ -z "$str" ]]; then
-    compadd -M 'r:|-=* r:|=*' -Q -s "$str" - \
+    compadd -M 'r:|-=* r:|=*' -Q - \
             "${(@P)name}" && ret=0
   fi
 done

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


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

* RE: PATCH: (was Re: _configure does not work)
  1999-03-09 10:32 Sven Wischnowsky
  1999-03-09 10:47 ` Andrej Borsenkow
@ 1999-03-09 11:36 ` Andrej Borsenkow
  1 sibling, 0 replies; 10+ messages in thread
From: Andrej Borsenkow @ 1999-03-09 11:36 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

After applying last patches (5696-5699) I get some strange results:

1. bor@itsrm2:/tools/src/zsh-3.1.5-pws-11%> ./configure --pre<TAB>
bor@itsrm2:/tools/src/zsh-3.1.5-pws-11%> ./configure --pre44
fix=

2. l ~/.z/C<TAB>
    Beep
~/.zsh.d/Completion exists and was correctly completed before a couple of
last patches :-)

3. (I think, it changed recently)

./configure --e-d<TAB>
./configure --enable-dynamic <^Xu> (bound to undo)
                             ^cursor here (one blank after line)
./configure --enable-dynamic <^Xu>
                             ^cursor still here
./configure --e-d

Well, IMHO ``--enable-dynamic '' (including blank) was inserted in _one_
step and should be removed by _one_ command as well. And it was the case at
least with 3-1.5-pws-10.

/andrej


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

* RE: PATCH: (was Re: _configure does not work)
  1999-03-09 10:32 Sven Wischnowsky
@ 1999-03-09 10:47 ` Andrej Borsenkow
  1999-03-09 11:36 ` Andrej Borsenkow
  1 sibling, 0 replies; 10+ messages in thread
From: Andrej Borsenkow @ 1999-03-09 10:47 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

>
> > itsrm2% ./configure --e-d<TAB>
> > itsrm2% ./configure
> >  (the whole stuff deleted)
> >
> > I'd thought, it completed to at least --enable-dynamic before.
>
> I think it didn't, I think it generated a list containing
> `--enable-dynamic', `--enable-zsh-debug' and others. This was wrong in
> the matching code in zle_tricky.c.
>

Why? I had impression, it was the result of matcher. If I say -M 'r:|-=*
r:|=*', then ``--e-d'' inevitably matches enable-zsh-debug. Should it not be
handled in matcher spec? "anything except -"?

/andrej


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

* PATCH: (was Re: _configure does not work)
@ 1999-03-09 10:32 Sven Wischnowsky
  1999-03-09 10:47 ` Andrej Borsenkow
  1999-03-09 11:36 ` Andrej Borsenkow
  0 siblings, 2 replies; 10+ messages in thread
From: Sven Wischnowsky @ 1999-03-09 10:32 UTC (permalink / raw)
  To: zsh-workers


Andrej Borsenkow wrote:

> (patches up to and including 5962)
> 
> bor@itsrm2:~%> zsh -f
> itsrm2% cd /tools/src
> itsrm2% cd zsh-3.1.5-pws-11 
> itsrm2% fpath=($PWD/Completion/*(/))
> itsrm2% source Completion/Core/compinit
> itsrm2% ./configure --prefix=/t<TAB>
>    B-e-e-p

The reason for this was that `_configure' didn't give a pattern and
action for things like `=PREFIX'. That's why I said I would like to
know about more patterns that should be used in the functions using
`_long_options'.

> itsrm2% ./configure --e-d<TAB>
> itsrm2% ./configure
>  (the whole stuff deleted)
> 
> I'd thought, it completed to at least --enable-dynamic before.

I think it didn't, I think it generated a list containing
`--enable-dynamic', `--enable-zsh-debug' and others. This was wrong in 
the matching code in zle_tricky.c.

Ok, the patch below changes zle_tricky.c to match only a sub-string up 
to a partial-word-separator for each such match spec and it changes
`_configure' to accept some more patterns.


Bye
 Sven

diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c	Mon Mar  8 10:23:41 1999
+++ Src/Zle/zle_tricky.c	Tue Mar  9 11:00:03 1999
@@ -3453,11 +3453,20 @@
 				 * characters are matched by the `*' pattern.
 				 * We do this by looping over the string
 				 * and calling this function recursively. */
-				int i = 0, j = iw, k = lw;
+				int i = 0, j = iw, k = lw, m = 0;
 				int jj = il + mp->llen, kk = ll - mp->llen;
 				char *p = l + mp->llen, *q = w;
 
 				for (; k; i++, j++, k--, q++) {
+				    if ((mp->flags & CMF_RIGHT) &&
+					(mp->right && k >= mp->ralen &&
+					 pattern_match(mp->right, q, 
+						       NULL, NULL))) {
+					if (m++) {
+					    k = 0;
+					    break;
+					}
+				    }
 				    if (match_pfx(p, q, NULL, NULL, NULL, NULL))
 					break;
 				}
@@ -3679,13 +3688,23 @@
 				     !pattern_match(mp->left, w - mp->lalen,
 						    NULL, NULL));
 			    if (t) {
-				int i = 0, j = iw, k = lw;
+				int i = 0, j = iw, k = lw, m = 0;
 				int jj = il + mp->llen, kk = ll - mp->llen;
 				char *p = l - mp->llen - 1, *q = w - 1;
 
-				for (; k; i++, j++, k--, q--)
+				for (; k; i++, j++, k--, q--) {
+				    if ((mp->flags & CMF_LEFT) &&
+					(mp->left && k >= mp->lalen &&
+					 pattern_match(mp->left, q - mp->lalen, 
+						       NULL, NULL))) {
+					if (m++) {
+					    k = 0;
+					    break;
+					}
+				    }
 				    if (match_pfx(p, q, NULL, NULL, NULL, NULL))
 					break;
+				}
 				if (k && i) {
 				    if (nlp) {
 					nw = addtoword(&rw, &rwlen, nw, mp,
@@ -4195,7 +4214,6 @@
 		t = s;
 		if (ppre)
 		    t = dyncat(ppre, t);
-		lc = NULL;
 		if (!cp && !ms && (mstack || psuf)) {
 		    int bl = ((aflags & CAF_MATCH) ? llpl : 0);
 		    Cline *clp = &lc, tlc;
diff -u oc/User/_configure Completion/User/_configure
--- oc/User/_configure	Mon Mar  8 11:05:13 1999
+++ Completion/User/_configure	Tue Mar  9 11:02:02 1999
@@ -1,3 +1,4 @@
 #defcomp configure
 
-_long_options
+_long_options '*=(E|)PREFIX*' '_files -/' \
+              '*=PROGRAM*'    '_command_names'

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


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

end of thread, other threads:[~1999-03-09 16:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-09 13:09 PATCH: (was Re: _configure does not work) Sven Wischnowsky
1999-03-09 13:37 ` Andrej Borsenkow
  -- strict thread matches above, loose matches on Subject: below --
1999-03-09 14:25 Sven Wischnowsky
1999-03-09 16:47 ` Andrej Borsenkow
1999-03-09 13:58 Sven Wischnowsky
1999-03-09 12:54 Sven Wischnowsky
1999-03-09 14:04 ` Andrej Borsenkow
1999-03-09 10:32 Sven Wischnowsky
1999-03-09 10:47 ` Andrej Borsenkow
1999-03-09 11:36 ` Andrej Borsenkow

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