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

Re: PATCH: completion regex handling



Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> } There are a few problems.  I couldn't work out how to add separators
> } other than space to a command added from within a regex argument
> } specifier.  It should have been possible to use _values -s, but for some
> } reason that didn't work.
> 
> I seem to recall some other places where _values doesn't work correctly.
> Maybe something related to the recursion problem mentioned in the thread
> spawned by zsh-workers/20618?

I don't think it's quite the same.

_values is doing something weird [traditional pause for amazed cries to die
away] with the separator.  It gets it with compvalues -s sep near the top,
then further down there's this:

      if [[ ${#noargs}+${#args}+${#opts} -ne 1 ]] && compvalues -s sep; then
        sep=( "-qS" "$sep" )
      else
        sep=()
      fi

If I comment out all but the second line it works the way I want (and,
playing with dd completion, I couldn't see any obvious adverse effects,
either, although presumably it's wrong if $sep isn't set).  CVS didn't give
much help: that second line was modified on 16th April 2002, the rest of
that chunk on 2nd April 2001, and the previous compvalues -s sep on 8th May
2001.

I'm testing it with this change to _regex_words, which is currently
only used when completing network realms, as in "ip route show realms ".
If it works, you get "cosmos/"; if it doesn't you get "cosmos ".

Index: Completion/Base/Utility/_regex_words
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_regex_words,v
retrieving revision 1.1
diff -u -r1.1 _regex_words
--- Completion/Base/Utility/_regex_words	25 Feb 2007 22:44:52 -0000	1.1
+++ Completion/Base/Utility/_regex_words	27 Feb 2007 12:35:11 -0000
@@ -33,7 +33,8 @@
   else
     # HERE: we should add the terminator instead of a space, but
     # there doesn't appear to be an easy way of doing that.
-    reply+=(":${tag}:${desc}:(( ${wds[1]//\*}${term//(#m)[: \(\)]/\\$MATCH}:${wds[2]//(#m)[: \(\)]/\\$MATCH} ))")
+    # reply+=(":${tag}:${desc}:(( ${wds[1]//\*}${term//(#m)[: \(\)]/\\$MATCH}:${wds[2]//(#m)[: \(\)]/\\$MATCH} ))")
+    reply+=(":${tag}:${desc}:_values -s $term ${wds[2]//(#m)[: \(\)]/\\$MATCH} ${wds[1]//\*}")
   fi
   eval "reply+=($wds[3])"
   if (( $i == $# )); then


-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php

To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview



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