zsh-workers
 help / color / mirror / code / Atom feed
* Re: completion with prefix which contains meta character.
@ 2000-01-07  9:27 Sven Wischnowsky
  0 siblings, 0 replies; 7+ messages in thread
From: Sven Wischnowsky @ 2000-01-07  9:27 UTC (permalink / raw)
  To: zsh-workers


Tanaka Akira wrote:

> In article <200001061503.QAA19187@beta.informatik.hu-berlin.de>,
>   Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes:
> 
> > Yup. Since $PREFIX contains the quoted form, compset should use it, too.
> 
> Now, `echo =<TAB>' completes nothing.

Ugh.

> ...
> 
> Replacing the compset pattern \= with = works well, but they should
> have same bahaviour, I think.

I first wanted to agree, then had a closer look at the quoting in the
completion code again and now I'm not so sure again.

Currently the completion code quotes only characters that need to be
quoted. And it reports only such characters (in $PREFIX and friends)
in quoted form.

With respect to this, the behaviour of compset is now consistent.

So the question is: should we change compset or not -- making it
differ from the rest? Or should we just document the way the code
quotes in the manual?

Still, here is the patch for _main_complete, the state this leaves the 
code in will stay valid independent of the answer for the questions
above.

Bye
 Sven

diff -ru ../z.old/Completion/Core/_main_complete Completion/Core/_main_complete
--- ../z.old/Completion/Core/_main_complete	Thu Jan  6 16:04:09 2000
+++ Completion/Core/_main_complete	Fri Jan  7 10:21:23 2000
@@ -38,7 +38,7 @@
 
 # Special completion contexts after `~' and `='.
 
-if compset -P 1 '\='; then
+if compset -P 1 '='; then
   compstate[context]=equal
 elif [[ "$PREFIX" != */* && "$PREFIX[1]" = '~' ]]; then
   compset -p 1

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


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

* Re: completion with prefix which contains meta character.
@ 2000-01-07 10:50 Sven Wischnowsky
  0 siblings, 0 replies; 7+ messages in thread
From: Sven Wischnowsky @ 2000-01-07 10:50 UTC (permalink / raw)
  To: zsh-workers


I wrote:

> ...
> 
> Still, here is the patch for _main_complete, the state this leaves the 
> code in will stay valid independent of the answer for the questions
> above.

Thought too late about looking at other uses of compset. Sorry.

Bye
 Sven

diff -ru ../z.old/Completion/Builtins/_hash Completion/Builtins/_hash
--- ../z.old/Completion/Builtins/_hash	Fri Jan  7 11:33:27 2000
+++ Completion/Builtins/_hash	Fri Jan  7 11:44:01 2000
@@ -3,13 +3,13 @@
 local expl
 
 if [[ "$words[2]" = -*d* ]]; then
-  if compset -P 1 '*\='; then
+  if compset -P 1 '*='; then
     _wanted -C -d-value files && _path_files -g '*(-/)'
   else
     _wanted -C -d named-directories expl 'named directory' &&
         compadd "$expl[@]" -q -S '=' - "${(@k)nameddirs}"
   fi
-elif compset -P 1 '*\='; then
+elif compset -P 1 '*='; then
   _wanted -C value values expl 'executable file' &&
       _files "$expl[@]" -g '*(*)'
 else
diff -ru ../z.old/Completion/Linux/_rpm Completion/Linux/_rpm
--- ../z.old/Completion/Linux/_rpm	Fri Jan  7 11:33:35 2000
+++ Completion/Linux/_rpm	Fri Jan  7 11:45:53 2000
@@ -202,7 +202,7 @@
   tags)
     if compset -P '*\{'; then
       _wanted tags expl 'RPM tag' &&
-          compadd "$expl[@]" -M 'm:{a-z}={A-Z}' -S '}' - \
+          compadd "$expl[@]" -M 'm:{a-z}={A-Z}' -S '\}' - \
                   "${(@)${(@f)$(rpm --querytags)}#RPMTAG_}" && ret=0
     else
       _message 'RPM format'
@@ -212,7 +212,7 @@
     _message 'RPM capability'
     ;;
   relocate)
-    if compset -P '*\='; then
+    if compset -P '*='; then
       _description directories expl 'new path'
     else
       _description directories expl 'old path'
diff -ru ../z.old/Completion/User/_dd Completion/User/_dd
--- ../z.old/Completion/User/_dd	Fri Jan  7 11:33:36 2000
+++ Completion/User/_dd	Fri Jan  7 11:46:17 2000
@@ -2,17 +2,17 @@
 
 local expl
 
-if compset -P 1 'conv\='; then
+if compset -P 1 'conv='; then
   # If there's a comma present, ignore up to the last one.  The
   # test alone will have that effect.
   compset -p '*,'
   _wanted values expl conversion &&
       compadd "$expl[@]" -qS, -q \
               ascii ebcdic ibm block unblock lcase ucase swab noerror sync
-elif compset -P 1 'if\='; then
+elif compset -P 1 'if='; then
   _description files expl 'input file'
   _files "$expl[@]"
-elif compset -P 1 'of\='; then
+elif compset -P 1 'of='; then
   _description files expl 'output file'
   _files "$expl[@]"
 else
diff -ru ../z.old/Completion/User/_gs Completion/User/_gs
--- ../z.old/Completion/User/_gs	Fri Jan  7 11:33:37 2000
+++ Completion/User/_gs	Fri Jan  7 11:46:34 2000
@@ -32,7 +32,7 @@
     fi
     ;;
   sname)
-    if compset -P '*\='; then
+    if compset -P '*='; then
       case "$IPREFIX" in
       *DEVICE\=)
         _wanted devices expl 'ghostscript device' &&
diff -ru ../z.old/Completion/User/_make Completion/User/_make
--- ../z.old/Completion/User/_make	Fri Jan  7 11:33:37 2000
+++ Completion/User/_make	Fri Jan  7 11:46:47 2000
@@ -24,5 +24,5 @@
  	      /^\.include  *<bsd\.port\.(subdir\.|pre\.)?mk>/ || /^\.include  *".*mk\/bsd\.pkg\.(subdir\.)?mk"/ {
  	        print "fetch fetch-list extract patch configure build install reinstall deinstall package describe checkpatch checksum makesum" }' \
  	     FS=: $file) && ret=0
-  (( ret )) && { compset -P 1 '*\='; _files }
+  (( ret )) && { compset -P 1 '*='; _files }
 fi

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


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

* Re: completion with prefix which contains meta character.
  2000-01-06 15:03 Sven Wischnowsky
@ 2000-01-06 23:38 ` Tanaka Akira
  0 siblings, 0 replies; 7+ messages in thread
From: Tanaka Akira @ 2000-01-06 23:38 UTC (permalink / raw)
  To: zsh-workers

In article <200001061503.QAA19187@beta.informatik.hu-berlin.de>,
  Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes:

> Yup. Since $PREFIX contains the quoted form, compset should use it, too.

Now, `echo =<TAB>' completes nothing.

Z:akr@is27e1u11% Src/zsh -f
is27e1u11% bindkey -e; autoload -U compinit; compinit -D
is27e1u11% echo =<TAB>

This completes nothing.

set -x on latest zsh says:
is27e1u11% echo =<TAB>
...
+_main_complete:41> compset -P 1 \=
+_main_complete:42> compstate[context]=equal 
...

set -x on 3.1.6-dev-14 says:
is27e1u11% echo =<TAB>
...
+_main_complete:41> compset -P 1 \=
+_main_complete:43> [[ = != */* && = == ~ ]]
...

Replacing the compset pattern \= with = works well, but they should
have same bahaviour, I think.
-- 
Tanaka Akira


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

* Re: completion with prefix which contains meta character.
@ 2000-01-06 15:03 Sven Wischnowsky
  2000-01-06 23:38 ` Tanaka Akira
  0 siblings, 1 reply; 7+ messages in thread
From: Sven Wischnowsky @ 2000-01-06 15:03 UTC (permalink / raw)
  To: zsh-workers


Tanaka Akira wrote:

> In article <200001060938.KAA17703@beta.informatik.hu-berlin.de>,
>   Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes:
> 
> > But it should. At least I wanted to get the -P and -S be used
> > literally (should be the most powerful, right?).
> 
> I agree. It's the most powerful way.
> 
> > Since I feel adventurous today, I even documented that.
> > 
> > And that rembslash() didn't make any sense at all.
> 
> Thanks.  Now compadd -P is useful even in these cases.  But I found
> similar problem about compset -P.
> 
> Z:akr@is27e1u11% Src/zsh -f
> is27e1u11% bindkey -e; autoload -U compinit; compinit -D; compdef _tst tst
> is27e1u11% _tst () { compset -P '\*' && compadd xxx } 
> is27e1u11% tst \*<TAB>
> 
> This completes nothing.
> 
> is27e1u11% _tst () { compset -P '\\\*' && compadd xxx }   
> is27e1u11% tst \*<TAB>
> 
> This completes nothing, too.
> 
> If compset -P tries to match against unquoted form of prefix, former
> should complete xxx.  If it tries to match against quoted form, latter
> should complete xxx.  But both completes nothing.

Yup. Since $PREFIX contains the quoted form, compset should use it, too.

Thanks.

Bye
 Sven

diff -ru ../z.old/Src/Zle/complete.c Src/Zle/complete.c
--- ../z.old/Src/Zle/complete.c	Thu Jan  6 13:52:33 2000
+++ Src/Zle/complete.c	Thu Jan  6 15:59:48 2000
@@ -894,11 +894,9 @@
 	break;
     case CVT_RANGEPAT:
 	tokenize(sa);
-	sa = rembslash(sa);
 	remnulargs(sa);
 	if (sb) {
 	    tokenize(sb);
-	    sb = rembslash(sb);
 	    remnulargs(sb);
 	}
 	break;
@@ -914,7 +912,6 @@
 	} else
 	    na = -1;
 	tokenize(sa);
-	sa = rembslash(sa);
 	remnulargs(sa);
 	break;
     }

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


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

* Re: completion with prefix which contains meta character.
  2000-01-06  9:38 Sven Wischnowsky
@ 2000-01-06 14:48 ` Tanaka Akira
  0 siblings, 0 replies; 7+ messages in thread
From: Tanaka Akira @ 2000-01-06 14:48 UTC (permalink / raw)
  To: zsh-workers

In article <200001060938.KAA17703@beta.informatik.hu-berlin.de>,
  Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes:

> But it should. At least I wanted to get the -P and -S be used
> literally (should be the most powerful, right?).

I agree. It's the most powerful way.

> Since I feel adventurous today, I even documented that.
> 
> And that rembslash() didn't make any sense at all.

Thanks.  Now compadd -P is useful even in these cases.  But I found
similar problem about compset -P.

Z:akr@is27e1u11% Src/zsh -f
is27e1u11% bindkey -e; autoload -U compinit; compinit -D; compdef _tst tst
is27e1u11% _tst () { compset -P '\*' && compadd xxx } 
is27e1u11% tst \*<TAB>

This completes nothing.

is27e1u11% _tst () { compset -P '\\\*' && compadd xxx }   
is27e1u11% tst \*<TAB>

This completes nothing, too.

If compset -P tries to match against unquoted form of prefix, former
should complete xxx.  If it tries to match against quoted form, latter
should complete xxx.  But both completes nothing.
-- 
Tanaka Akira


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

* Re: completion with prefix which contains meta character.
@ 2000-01-06  9:38 Sven Wischnowsky
  2000-01-06 14:48 ` Tanaka Akira
  0 siblings, 1 reply; 7+ messages in thread
From: Sven Wischnowsky @ 2000-01-06  9:38 UTC (permalink / raw)
  To: zsh-workers


Tanaka Akira wrote:

> I tried to complete with prefix `*' but zsh doesn't work well.
> 
> Z(2):akr@is27e1u11% Src/zsh -f
> is27e1u11% bindkey -e; autoload -U compinit; compinit -D; compdef _tst tst
> is27e1u11% _tst () { compadd -P '*' xxx }
> is27e1u11% tst \*<TAB>
> 
> This doesn't complete anything.
> 
> is27e1u11% _tst () { compadd -P '\*' xxx } 
> is27e1u11% tst \*<TAB>
> 
> This doesn't complete anything too.

But it should. At least I wanted to get the -P and -S be used
literally (should be the most powerful, right?).

Since I feel adventurous today, I even documented that.

And that rembslash() didn't make any sense at all.

Bye
 Sven

diff -ru ../z.old/Doc/Zsh/compwid.yo Doc/Zsh/compwid.yo
--- ../z.old/Doc/Zsh/compwid.yo	Thu Jan  6 10:27:21 2000
+++ Doc/Zsh/compwid.yo	Thu Jan  6 10:37:22 2000
@@ -420,7 +420,8 @@
 startitem()
 item(tt(-P) var(prefix))(
 This gives a string to be inserted before the given var(words).  The
-string given is not considered as part of the match.
+string given is not considered as part of the match and any shell
+metacharacters in it will not be quoted when the string is inserted.
 )
 item(tt(-S) var(suffix))(
 Like tt(-P) but gives a string to be inserted after the match.
diff -ru ../z.old/Src/Zle/compcore.c Src/Zle/compcore.c
--- ../z.old/Src/Zle/compcore.c	Thu Jan  6 10:27:14 2000
+++ Src/Zle/compcore.c	Thu Jan  6 10:32:46 2000
@@ -1629,9 +1629,7 @@
 		llsl = strlen(lsuf);
 		/* Test if there is an existing -P prefix. */
 		if (dat->pre && *dat->pre) {
-		    char *dp = rembslash(dat->pre);
-
-		    pl = pfxlen(dp, lpre);
+		    pl = pfxlen(dat->pre, lpre);
 		    llpl -= pl;
 		    lpre += pl;
 		}

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


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

* completion with prefix which contains meta character.
@ 2000-01-06  8:04 Tanaka Akira
  0 siblings, 0 replies; 7+ messages in thread
From: Tanaka Akira @ 2000-01-06  8:04 UTC (permalink / raw)
  To: zsh-workers

I tried to complete with prefix `*' but zsh doesn't work well.

Z(2):akr@is27e1u11% Src/zsh -f
is27e1u11% bindkey -e; autoload -U compinit; compinit -D; compdef _tst tst
is27e1u11% _tst () { compadd -P '*' xxx }
is27e1u11% tst \*<TAB>

This doesn't complete anything.

is27e1u11% _tst () { compadd -P '\*' xxx } 
is27e1u11% tst \*<TAB>

This doesn't complete anything too.

is27e1u11% _tst () { compadd -P '\\*' xxx }
is27e1u11% tst \*<TAB>
->
is27e1u11% tst \\*xxx 

This re-quotes `\'.  Anyway, current behaviour is unusable.
-- 
Tanaka Akira


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

end of thread, other threads:[~2000-01-07 11:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-07  9:27 completion with prefix which contains meta character Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
2000-01-07 10:50 Sven Wischnowsky
2000-01-06 15:03 Sven Wischnowsky
2000-01-06 23:38 ` Tanaka Akira
2000-01-06  9:38 Sven Wischnowsky
2000-01-06 14:48 ` Tanaka Akira
2000-01-06  8:04 Tanaka Akira

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