zsh-workers
 help / color / mirror / code / Atom feed
* Bug in zsh_directory_name_cdr completion?
@ 2011-08-03 13:42 Nikolai Weibull
  2011-08-03 14:58 ` Mikael Magnusson
  2011-08-03 20:06 ` Peter Stephenson
  0 siblings, 2 replies; 5+ messages in thread
From: Nikolai Weibull @ 2011-08-03 13:42 UTC (permalink / raw)
  To: Zsh Workers

Hi!

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.

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?

Also, I’m unable to use list-colors together with the dir-index tag:

zstyle ':completion:*:*:-subscript-:*:dir-index' list-colors …

What am I doing wrong?


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

* Re: Bug in zsh_directory_name_cdr completion?
  2011-08-03 13:42 Bug in zsh_directory_name_cdr completion? Nikolai Weibull
@ 2011-08-03 14:58 ` Mikael Magnusson
  2011-08-03 20:06 ` Peter Stephenson
  1 sibling, 0 replies; 5+ messages in thread
From: Mikael Magnusson @ 2011-08-03 14:58 UTC (permalink / raw)
  To: Nikolai Weibull; +Cc: Zsh Workers

On 3 August 2011 15:42, Nikolai Weibull <now@bitwi.se> wrote:
> Hi!
>
> 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.
>
> Also, wouldn’t it be nice if cd ~[1]/<Tab> would offer completions
> under the most recent directory

Completing at this point works for me sometimes and sometimes not,
I've not yet been able to determine when it does and when it doesn't.
It would also be nice if cd ~[foo]<tab> produced a /.

> perhaps even expanding ~[1] to the
> directory’s name so that the history gets the benefit of the
> non-contextual directory name?

There's always the expand-word widget. (Which works for me even when
completion doesn't want to list the contents).

-- 
Mikael Magnusson


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

* Re: Bug in zsh_directory_name_cdr completion?
  2011-08-03 13:42 Bug in zsh_directory_name_cdr completion? Nikolai Weibull
  2011-08-03 14:58 ` Mikael Magnusson
@ 2011-08-03 20:06 ` Peter Stephenson
  2011-08-04 11:58   ` Nikolai Weibull
  1 sibling, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2011-08-03 20:06 UTC (permalink / raw)
  To: Zsh Workers

On Wed, 3 Aug 2011 15:42:38 +0200
Nikolai Weibull <now@bitwi.se> 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@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


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

* Re: Bug in zsh_directory_name_cdr completion?
  2011-08-03 20:06 ` Peter Stephenson
@ 2011-08-04 11:58   ` Nikolai Weibull
  2011-08-04 12:10     ` Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: Nikolai Weibull @ 2011-08-04 11:58 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh Workers

On Wed, Aug 3, 2011 at 22:06, Peter Stephenson
<p.w.stephenson@ntlworld.com> wrote:
> On Wed, 3 Aug 2011 15:42:38 +0200
> Nikolai Weibull <now@bitwi.se> wrote:

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

Shouldn’t expand-or-complete do this for me?  For some reason it seems
that it wants to offer me parameters instead when pressing Tab at cd
~[1]/<Tab>.


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

* Re: Bug in zsh_directory_name_cdr completion?
  2011-08-04 11:58   ` Nikolai Weibull
@ 2011-08-04 12:10     ` Peter Stephenson
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2011-08-04 12:10 UTC (permalink / raw)
  To: Zsh Workers

On Thu, 4 Aug 2011 13:58:55 +0200
Nikolai Weibull <now@bitwi.se> wrote:
> On Wed, Aug 3, 2011 at 22:06, Peter Stephenson
> <p.w.stephenson@ntlworld.com> wrote:
> > On Wed, 3 Aug 2011 15:42:38 +0200
> > Nikolai Weibull <now@bitwi.se> wrote:
> 
> >> 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.
> 
> Shouldn’t expand-or-complete do this for me?  For some reason it seems
> that it wants to offer me parameters instead when pressing Tab at cd
> ~[1]/<Tab>.

Tilde completion has never triggered expansion here, and
expand-or-complete is a builtin function rather than a configurable
widget, so this is as expected.  Configuring the _expand
completer is possible.  I think setting the keep-prefix style to false
is enough to trigger expansion with that (unless you've got it
configured only to do substitutions).  We can make a more specific
style if it seems useful.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK



Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


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

end of thread, other threads:[~2011-08-04 12:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-03 13:42 Bug in zsh_directory_name_cdr completion? Nikolai Weibull
2011-08-03 14:58 ` Mikael Magnusson
2011-08-03 20:06 ` Peter Stephenson
2011-08-04 11:58   ` Nikolai Weibull
2011-08-04 12:10     ` Peter Stephenson

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