zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-users@sunsite.auc.dk (Zsh users list),
	Richard Curnow <Richard.Curnow@st.com>
Subject: Re: How to avoid expansion when completing?
Date: Thu, 03 Aug 2000 10:19:05 +0100	[thread overview]
Message-ID: <0FYP004HWLVT39@la-la.cambridgesiliconradio.com> (raw)
In-Reply-To: "Your message of Thu, 03 Aug 2000 08:51:26 BST." <20000803085126.I13662@bri.st.com>

> Suppose I have a load of subdirectories, each of which contains a file
> called foobar.dat.  I enter 
> 
> % wc **/foob<Tab>
> 
> hoping to expand this to **/foobar.dat (assuming there's nothing else
> starting with 'foob' in any of the subdirectories).  However, I get the
> '**' expanded to the first subdirectory name which has a file starting
> with 'foob' in it.  (If I keep pressing <Tab> then I cycle round).
> 
> I've got the following options set, and I'm running version 3.1.5.

If you don't mind upgrading, you can do such things with the new bindable
completion widgets in 3.1.9 (maybe 3.1.6, but that's irrelevant if you're
still on 3.1.5).  Assuming the file is unique, you can use
e.g. _most_recent_file (usually bound to ^xm), which would normally put a
`*' on the end and find the most recently modified matching file --- that
ought to be enough for this purpose.

The following function is a trivial modification of that to add all
matching files as possible completions (_glob_expand_and_complete).
Sven probably has a better way of doing it.


#compdef -k complete-word \C-xG

local file tilde etilde
if [[ $PREFIX = \~*/* ]]; then
  tilde=${PREFIX%%/*}
  etilde=${~tilde}
  file=($~PREFIX*$~SUFFIX)
  file=(${file/#$etilde/$tilde})
else
  file=($~PREFIX*$~SUFFIX)
fi
(( $#file )) && compadd -U -i "$IPREFIX" -I "$ISUFFIX" -f -Q $file


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


  reply	other threads:[~2000-08-03  9:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-08-03  7:51 Richard Curnow
2000-08-03  9:19 ` Peter Stephenson [this message]
2000-08-03 10:51 Sven Wischnowsky

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=0FYP004HWLVT39@la-la.cambridgesiliconradio.com \
    --to=pws@csr.com \
    --cc=Richard.Curnow@st.com \
    --cc=zsh-users@sunsite.auc.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).