Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug in zsh_directory_name_cdr completion?



On Wed, 3 Aug 2011 15:42:38 +0200
Nikolai Weibull <now@xxxxxxxx> wrote:
> There seems to be a bug in zsh_directory_name_cdr_completion.  When
> trying to complete anything but the most recent directory, the
> completion fails with “no matches for `recent directory index'”.  That
> is, cd ~[1<Tab> works, but cd ~[8<Tab> doesn’t.

This must be a bug in _describe, but there's no way I'm going to start
looking at that.  Luckily, simply passing one array is good enough (the keys
are the same as the strings before the first ":").

The remainder is just some tidying while I was looking at the C code,
although it turns out that doesn't need fixing.

> Also, wouldn’t it be nice if cd ~[1]/<Tab> would offer completions
> under the most recent directory, perhaps even expanding ~[1] to the
> directory’s name so that the history gets the benefit of the
> non-contextual directory name?

The expansion bit should work already with the right completers.

Index: Functions/Chpwd/zsh_directory_name_cdr
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Chpwd/zsh_directory_name_cdr,v
retrieving revision 1.1
diff -p -u -r1.1 zsh_directory_name_cdr
--- Functions/Chpwd/zsh_directory_name_cdr	11 Mar 2011 16:32:10 -0000	1.1
+++ Functions/Chpwd/zsh_directory_name_cdr	3 Aug 2011 20:02:41 -0000
@@ -18,7 +18,7 @@ elif [[ $1 = c ]]; then
     values=(${${(f)"$(cdr -l)"}/ ##/:})
     keys=(${values%%:*})
     _describe -t dir-index 'recent directory index' \
-      values keys -V unsorted -S']'
+      values -V unsorted -S']'
     return
   fi
 fi
Index: Src/Zle/compcore.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v
retrieving revision 1.110
diff -p -u -r1.110 compcore.c
--- Src/Zle/compcore.c	19 Jun 2011 16:26:11 -0000	1.110
+++ Src/Zle/compcore.c	3 Aug 2011 19:58:37 -0000
@@ -607,7 +607,7 @@ callcompfunc(char *s, char *fn)
 	    if (rdstr)
 		compredirect = rdstr;
 	    kset |= CP_REDIRECT;
-	} else
+	} else {
 	    switch (linwhat) {
 	    case IN_ENV:
 		compcontext = (linarr ? "array_value" : "value");
@@ -637,6 +637,7 @@ callcompfunc(char *s, char *fn)
 		    aadd = 1;
 		}
 	    }
+	}
 	compcontext = ztrdup(compcontext);
 	if (compwords)
 	    freearray(compwords);
Index: Src/Zle/zle_tricky.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_tricky.c,v
retrieving revision 1.111
diff -p -u -r1.111 zle_tricky.c
--- Src/Zle/zle_tricky.c	23 Jun 2011 19:29:24 -0000	1.111
+++ Src/Zle/zle_tricky.c	3 Aug 2011 19:58:37 -0000
@@ -398,7 +398,18 @@ mod_export char *cmdstr;
 /**/
 mod_export char *varname;
 
-/* != 0 if we are in a subscript */
+/*
+ * != 0 if we are in a subscript.
+ * Of course, this being the completion code, you're expected to guess
+ * what the different numbers actually mean, but here's a cheat:
+ * 1: Key of an ordinary array
+ * 2: Key of a hash
+ * 3: Ummm.... this appears to be a special case of 2.  After a lot
+ *    of uncommented code looking for groups of brackets, we suddenly
+ *    decide to set it to 2.  The only upshot seems to be that compctl
+ *    then doesn't add a matching ']' at the end, so I think it means
+ *    there's one there already.
+ */
 
 /**/
 mod_export int insubscr;


-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



Messages sorted by: Reverse Date, Date, Thread, Author