zsh-workers
 help / color / mirror / code / Atom feed
* = completion
@ 2005-11-26 19:22 Seth Kurtzberg
  2005-11-27  8:21 ` Andrey Borzenkov
  0 siblings, 1 reply; 6+ messages in thread
From: Seth Kurtzberg @ 2005-11-26 19:22 UTC (permalink / raw)
  To: zsh-workers

All,

I'm either having a problem, or misunderstanding what I should expect,
in the following situation.

With the following, tab completion works as expected:

    abc=(/whatever $abc)

(I'm doing tab completion on the /whatever)

In each of the following, however, tab completion does not work (that
is, no completion occurs):

    export abc=/whatever:$abc   (obviously I attempt tab completion
before adding the :$abc)

    dd if=./whatever

The latter is an example of using arg=/some/path which occurs for
various commands, so dd is just an example and the question is not in
any way specific to dd.

I do have the options related to equals completion enabled.

I also tried this on a new install of linux with no changes to any of
the zsh startup files (no changes in /etc and the default .zshrc file in
$HOME) with the same results.  Eliminating $HOME/.zshrc also did not
change the behavior.

Is there a way to make completion work in these situations?

Seth



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

* Re: = completion
  2005-11-26 19:22 = completion Seth Kurtzberg
@ 2005-11-27  8:21 ` Andrey Borzenkov
  2005-11-27 14:06   ` Seth Kurtzberg
  0 siblings, 1 reply; 6+ messages in thread
From: Andrey Borzenkov @ 2005-11-27  8:21 UTC (permalink / raw)
  To: zsh-workers, seth

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Saturday 26 November 2005 22:22, Seth Kurtzberg wrote:
>
> In each of the following, however, tab completion does not work (that
> is, no completion occurs):
>
>     export abc=/whatever:$abc   (obviously I attempt tab completion
> before adding the :$abc)
>

Works fine and with COMPLETE_IN_WORD set also in the middle of string

>     dd if=./whatever
>

Of course works too.

Which zsh version and completion style do you use? I am not sure if compctl 
does what you want (I have not used it for years) but new compsys does. If 
you have zsh 4.2.x, try

autoload -U compinit; compinit

to initialize completion system.

> The latter is an example of using arg=/some/path which occurs for
> various commands, so dd is just an example and the question is not in
> any way specific to dd.
>

It is. Completion is context-sensitive. It knows that export expects 
(path-)assignment; that for dd if= has path as argument; but it has no way to 
know this for arbitrary command "foo". While it is possible to fallback to 
something like dd does, I am now sure it is good idea; you probably need it 
only for several commands and it is likely zsh already includes suitable 
completion for them.

> I do have the options related to equals completion enabled.
>

Which suggests you are using compctl.

> I also tried this on a new install of linux

This satement is meaningless :) Which distribution, which version? Some of 
them may use compsys by default some not. Anyway, just try compinit as above 
and if it works, try compinstall that will help you to setup new completion 
system.

BTW zsh-users would be more appropriate for such questions.

- -andrey
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDiWyiR6LMutpd94wRAkHWAJ9eBvoUlJre1se/GdN0hJ5aw7wSrwCgsIgb
rK26xHma2Fcr9v1cxi5dPak=
=NVS1
-----END PGP SIGNATURE-----


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

* Re: = completion
  2005-11-27  8:21 ` Andrey Borzenkov
@ 2005-11-27 14:06   ` Seth Kurtzberg
  0 siblings, 0 replies; 6+ messages in thread
From: Seth Kurtzberg @ 2005-11-27 14:06 UTC (permalink / raw)
  To: Andrey Borzenkov; +Cc: zsh-workers

On Sun, 2005-11-27 at 11:21 +0300, Andrey Borzenkov wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On Saturday 26 November 2005 22:22, Seth Kurtzberg wrote:
> >
> > In each of the following, however, tab completion does not work (that
> > is, no completion occurs):
> >
> >     export abc=/whatever:$abc   (obviously I attempt tab completion
> > before adding the :$abc)
> >
> 
> Works fine and with COMPLETE_IN_WORD set also in the middle of string
> 
> >     dd if=./whatever
> >
> 
> Of course works too.
> 
> Which zsh version and completion style do you use? I am not sure if compctl 
> does what you want (I have not used it for years) but new compsys does. If 
> you have zsh 4.2.x, try
> 
> autoload -U compinit; compinit

Thanks much, this indeed took care of the problem.  I didn't realize
that this wasn't the default.

I'll use the users list next time.

> 
> to initialize completion system.
> 
> > The latter is an example of using arg=/some/path which occurs for
> > various commands, so dd is just an example and the question is not in
> > any way specific to dd.
> >
> 
> It is. Completion is context-sensitive. It knows that export expects 
> (path-)assignment; that for dd if= has path as argument; but it has no way to 
> know this for arbitrary command "foo". While it is possible to fallback to 
> something like dd does, I am now sure it is good idea; you probably need it 
> only for several commands and it is likely zsh already includes suitable 
> completion for them.
> 
> > I do have the options related to equals completion enabled.
> >
> 
> Which suggests you are using compctl.
> 
> > I also tried this on a new install of linux
> 
> This satement is meaningless :) Which distribution, which version? Some of 
> them may use compsys by default some not. Anyway, just try compinit as above 
> and if it works, try compinstall that will help you to setup new completion 
> system.
> 
> BTW zsh-users would be more appropriate for such questions.
> 
> - -andrey
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2 (GNU/Linux)
> 
> iD8DBQFDiWyiR6LMutpd94wRAkHWAJ9eBvoUlJre1se/GdN0hJ5aw7wSrwCgsIgb
> rK26xHma2Fcr9v1cxi5dPak=
> =NVS1
> -----END PGP SIGNATURE-----
> 


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

* Re: \# completion
@ 2000-08-08 10:30 Sven Wischnowsky
  0 siblings, 0 replies; 6+ messages in thread
From: Sven Wischnowsky @ 2000-08-08 10:30 UTC (permalink / raw)
  To: zsh-workers


Peter Stephenson wrote:

> Unless it's me,
>   rm \#<TAB>
> isn't working at the moment, although
>   rm '#<TAB>
> is.
> 
>   rm #<TAB>
> doesn't work either --- I wouldn't particularly expect it to, so I'm not
> worried, but I recall it did several generations of completion code ago,
> which is the last time I can remember trying it.

I'm very confused, because I was sure that I had tested it. Dunno what 
went wrong, maybe I committed an earlier version. Sorry.

The same for the dependency on _expand Bart noted.


Tanaka Akira wrote:

> \ has the problem yet.
> 
> Z(2):akr@flux% Src/zsh -f  
> flux% bindkey -e; autoload -U compinit; compinit -D
> flux% mkdir -p '\ab/cd'
> flux% ls \\<TAB>
> 
> This completes nothing.

Huh? This worked for me.

> I made a test to check this problem and found other problems.
> 
> flux% mkdir -p '=ab/cd'
> flux% ls \=<TAB>
> _path_files:327: * not found

But this didn't. Forgot to test for the `=' character in compfiles.


> Note that the completion with = behaves curiously as follows.
> 
> flux% ls ./=<TAB>
> flux% ls ./\=ab/<TAB>
> flux% ls ./=ab/cd/

Urgh. The problem was that the compquote builtin quoted the `=' when
completing `=ab', because it didn't know that there was a prefix.

So, the patch adds the `-p' option to compquote to tell it about an
existing prefix.

> Also note that metafied characters (0x83 to 0x9c) is printed in
> metafied form.

I couldn't reproduce this.


Bye
 Sven

Index: Completion/Core/_expand
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_expand,v
retrieving revision 1.27
diff -u -r1.27 _expand
--- Completion/Core/_expand	2000/08/03 13:35:44	1.27
+++ Completion/Core/_expand	2000/08/08 10:29:37
@@ -63,7 +63,7 @@
       eval exp\=\( ${${(q)exp}:gs/\\{/\{/:gs/\\}/\}/} \)
   eval 'exp=( ${${(e)exp//\\[ 	
 ]/ }//(#b)([ 	
-\\])/\\$match[1]} )' 2>/dev/null
+])/\\$match[1]} )' 2>/dev/null
 else
   exp=( ${exp:s/\\\$/\$} )
 fi
@@ -77,14 +77,14 @@
 # Now try globbing.
 
 [[ "$force" = *g* ]] || zstyle -T ":completion:${curcontext}:" glob &&
-    eval 'exp=( ${~exp} ); exp=( ${exp//(#b)([][()|*?^#~<>\\])/\\${match[1]}} )' 2>/dev/null
+    eval 'exp=( ${~exp} ); exp=( ${exp//(#b)([][()|*?^#~<>\\=])/\\${match[1]}} )' 2>/dev/null
 
 # If we don't have any expansions or only one and that is the same
 # as the original string, we let other completers run.
 
 (( $#exp )) || exp=("$subd[@]")
 
-[[ $#exp -eq 1 && "$exp[1]" = "$word"(|\(N\)) ]] && return 1
+[[ $#exp -eq 1 && "${exp[1]//\\}" = "${word//\\}"(|\(N\)) ]] && return 1
 
 # With subst-globs-only we bail out if there were no glob expansions,
 # regardless of any substitutions
Index: Completion/Core/_path_files
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_path_files,v
retrieving revision 1.29
diff -u -r1.29 _path_files
--- Completion/Core/_path_files	2000/08/03 13:35:44	1.29
+++ Completion/Core/_path_files	2000/08/08 10:29:38
@@ -421,7 +421,7 @@
     # There are more components, so skip over the next components and make a
     # slash be added.
 
-    tmp1=( ${tmp1//(#b)([][()|*?^#~<>\\])/\\${match[1]}} )
+    tmp1=( ${tmp1//(#b)([][()|*?^#~<>\\=])/\\${match[1]}} )
     tmp2="${(M)tpre##((.|..|)/)##}"
     if [[ -n "$tmp2" ]]; then
       skipped="/$tmp2"
@@ -470,7 +470,14 @@
       # it as far as possible.
 
       tmp2="$testpath"
-      compquote tmp1 tmp2
+      if [[ -n "$linepath" ]]; then
+        compquote -p tmp2 tmp1
+      elif [[ -n "$tmp2" ]]; then
+        compquote -p tmp1
+        compquote tmp2
+      else
+        compquote tmp1 tmp2
+      fi
 
       if [[ -n $menu || -z "$compstate[insert]" ]] ||
          ! zstyle -t ":completion:${curcontext}:paths" expand suffix; then
@@ -544,7 +551,12 @@
       tmp4="${testpath#${mid}}"
       tmp3="${mid%/*/}"
       tmp2="${${mid%/}##*/}"
-      compquote tmp4 tmp3 tmp2 tmp1
+      if [[ -n "$linepath" ]]; then
+        compquote -p tmp3
+      else
+        compquote tmp3
+      fi
+      compquote tmp4 tmp2 tmp1
       for i in "$tmp1[@]"; do
         compadd -Qf "$mopts[@]" -p "$linepath$tmp3/" -s "/$tmp4$i" \
                 -W "$prepath$realpath${mid%/*/}/" \
@@ -559,7 +571,14 @@
         SUFFIX="${osuf}"
       fi
       tmp4="$testpath"
-      compquote tmp4 tmp1
+      if [[ -n "$linepath" ]]; then
+        compquote -p tmp4 tmp1
+      elif [[ -n "$tmp4" ]]; then
+        compquote -p tmp1
+        compquote tmp4
+      else
+        compquote tmp4 tmp1
+      fi
       compadd -Qf "$mopts[@]" -p "$linepath$tmp4" -W "$prepath$realpath$testpath" \
 	      "$pfxsfx[@]" -M "r:|/=* r:|=*" -a tmp1
     fi
Index: Doc/Zsh/mod_computil.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/mod_computil.yo,v
retrieving revision 1.5
diff -u -r1.5 mod_computil.yo
--- Doc/Zsh/mod_computil.yo	2000/06/26 08:36:43	1.5
+++ Doc/Zsh/mod_computil.yo	2000/08/08 10:29:39
@@ -61,7 +61,7 @@
 duplicates and with removing consecutive duplicates).
 )
 findex(compquote)
-item(tt(compquote) var(names) ...)(
+item(tt(compquote) [ tt(-p) ] var(names) ...)(
 There may be reasons to write completion functions that have to add
 the matches using the tt(-Q) option to tt(compadd) and perform quoting
 themselves.  Instead of interpreting the first character of the
@@ -69,7 +69,9 @@
 the tt(q) flag for parameter expansions, one can use this builtin
 command.  The arguments are the names of scalar or array parameters
 and the values of these parameters are quoted as needed for the
-innermost quoting level.
+innermost quoting level.  If the tt(-p) option is given, quoting is
+done as if there is some prefix before the values of the parameters,
+so that a leading equal sign will not be quoted.
 
 The return value is non-zero in case of an error and zero otherwise.
 )
Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.39
diff -u -r1.39 computil.c
--- Src/Zle/computil.c	2000/07/27 08:32:02	1.39
+++ Src/Zle/computil.c	2000/08/08 10:29:42
@@ -2559,6 +2559,24 @@
     return 1;
 }
 
+static char *
+comp_quote(char *str, int prefix)
+{
+    int x;
+    char *ret;
+
+    if ((x = (prefix && *str == '=')))
+	*str = 'x';
+
+    ret = bslashquote(str, NULL, (*compqstack == '\'' ? 1 :
+				  (*compqstack == '"' ? 2 : 0)));
+
+    if (x)
+	*str = *ret = '=';
+
+    return ret;
+}
+
 static int
 bin_compquote(char *nam, char **args, char *ops, int func)
 {
@@ -2578,15 +2596,7 @@
 	if ((v = getvalue(&vbuf, &name, 0))) {
 	    switch (PM_TYPE(v->pm->flags)) {
 	    case PM_SCALAR:
-		{
-		    char *val = getstrvalue(v);
-
-		    val = bslashquote(val, NULL,
-				      (*compqstack == '\'' ? 1 :
-				       (*compqstack == '"' ? 2 : 0)));
-
-		    setstrvalue(v, ztrdup(val));
-		}
+		setstrvalue(v, ztrdup(comp_quote(getstrvalue(v), ops['p'])));
 		break;
 	    case PM_ARRAY:
 		{
@@ -2596,10 +2606,7 @@
 		    char **p = new;
 
 		    for (; *val; val++, p++)
-			*p = ztrdup(bslashquote(*val, NULL,
-						(*compqstack == '\'' ? 1 :
-						 (*compqstack == '"' ? 2 :
-						  0))));
+			*p = ztrdup(comp_quote(*val, ops['p']));
 		    *p = NULL;
 
 		    setarrvalue(v, new);
@@ -3242,11 +3249,12 @@
 	if (*s != '\\' || !s[1] || s[1] == '*' || s[1] == '?' ||
 	    s[1] == '<' || s[1] == '>' || s[1] == '(' || s[1] == ')' ||
 	    s[1] == '[' || s[1] == ']' || s[1] == '|' || s[1] == '#' ||
-	    s[1] == '^' || s[1] == '~') {
+	    s[1] == '^' || s[1] == '~' || s[1] == '=') {
 	    if ((s == compprefix || s[-1] != '\\') &&
 		(*s == '*' || *s == '?' || *s == '<' || *s == '>' ||
 		 *s == '(' || *s == ')' || *s == '[' || *s == ']' ||
-		 *s == '|' || *s == '#' || *s == '^' || *s == '~'))
+		 *s == '|' || *s == '#' || *s == '^' || *s == '~' ||
+		 *s == '='))
 		*t++ = '\\';
 	    *t++ = *s;
 	}
@@ -3653,7 +3661,7 @@
     BUILTIN("compdescribe", 0, bin_compdescribe, 3, -1, 0, NULL, NULL),
     BUILTIN("comparguments", 0, bin_comparguments, 1, -1, 0, NULL, NULL),
     BUILTIN("compvalues", 0, bin_compvalues, 1, -1, 0, NULL, NULL),
-    BUILTIN("compquote", 0, bin_compquote, 1, -1, 0, NULL, NULL),
+    BUILTIN("compquote", 0, bin_compquote, 1, -1, 0, "p", NULL),
     BUILTIN("comptags", 0, bin_comptags, 1, -1, 0, NULL, NULL),
     BUILTIN("comptry", 0, bin_comptry, 0, -1, 0, NULL, NULL),
     BUILTIN("compfiles", 0, bin_compfiles, 1, -1, 0, NULL, NULL),

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


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

* Re: \# completion
  2000-08-04 14:33 Peter Stephenson
@ 2000-08-05 16:41 ` Bart Schaefer
  0 siblings, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 2000-08-05 16:41 UTC (permalink / raw)
  To: Peter Stephenson, Zsh hackers list

On Aug 4,  3:33pm, Peter Stephenson wrote:
} Subject: \# completion
}
} Unless it's me,
}   rm \#<TAB>
} isn't working at the moment, although
}   rm '#<TAB>
} is.

This looks to be a problem with _expand.  Using _expand:

zagzig[234] rm \#<TAB>
zagzig[234] rm \\#
Completing all expansions
\\# 
Completing original
\# 

Without _expand:

zagzig[244] rm \#<TAB>
zagzig[244] rm \#xxx\#

}   rm #<TAB>
} doesn't work either

That one, however, works for me, both with and without _expand:

zagzig[234] rm #<TAB>
zagzig[234] rm \#xxx\#

zagzig[244] rm #<TAB>
zagzig[244] rm \#xxx\#

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* \# completion
@ 2000-08-04 14:33 Peter Stephenson
  2000-08-05 16:41 ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Stephenson @ 2000-08-04 14:33 UTC (permalink / raw)
  To: Zsh hackers list

Unless it's me,
  rm \#<TAB>
isn't working at the moment, although
  rm '#<TAB>
is.

  rm #<TAB>
doesn't work either --- I wouldn't particularly expect it to, so I'm not
worried, but I recall it did several generations of completion code ago,
which is the last time I can remember trying it.

The contents of the directory are
  #psbc01.h#              module_manufacturers.h  psbc01.c
  CVS/                    ps.c                    psbc01.h
  Makefile                ps.h                    psbc01.lif
  README                  ps.lif                  psbc01.xap
  extract_keys.pl*        ps.xap                  xaplibps
  extract_keys.pl~        ps_private.h
if it helps.

-- 
Peter Stephenson <pws@csr.com>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


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

end of thread, other threads:[~2005-11-27 14:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-26 19:22 = completion Seth Kurtzberg
2005-11-27  8:21 ` Andrey Borzenkov
2005-11-27 14:06   ` Seth Kurtzberg
  -- strict thread matches above, loose matches on Subject: below --
2000-08-08 10:30 \# completion Sven Wischnowsky
2000-08-04 14:33 Peter Stephenson
2000-08-05 16:41 ` 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).