zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: Re: PATCH: completion regex handling
Date: Tue, 27 Feb 2007 12:41:05 +0000	[thread overview]
Message-ID: <20070227124105.8208c36c.pws@csr.com> (raw)
In-Reply-To: <070226001857.ZM8988@torch.brasslantern.com>

Bart Schaefer <schaefer@brasslantern.com> 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@csr.com>                  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


  reply	other threads:[~2007-02-27 12:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-25 22:37 Peter Stephenson
2007-02-26  8:18 ` Bart Schaefer
2007-02-27 12:41   ` Peter Stephenson [this message]
2007-02-27 16:46     ` Bart Schaefer
2007-02-27 20:35       ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070227124105.8208c36c.pws@csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).