zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: Zsh Users <zsh-users@sunsite.dk>
Subject: Re: echo-ing case insensitively
Date: Sun, 23 Feb 2003 01:47:30 +0000	[thread overview]
Message-ID: <1030223014730.ZM11489@candle.brasslantern.com> (raw)
In-Reply-To: <20030213145737.GF2260@fruitcom.com>

[I've been on vacation for a week, hence the long delay in responding ...
also, I've just noticed that my machine rebooted with the clock off by an
hour, so this message may appear to have been sent before others I sent
earlier.  Sigh.]

On Feb 13,  3:57pm, Eric Smith wrote:
>
> <rant>
> Well I find directories that enforce a one-dimensional hierarchy
> very restrictive and maps poorly to the real world.  Accordingly
> I use underscores in filenames to create "namespaces" like others would
> create dirs.  But the freedom of not using directories allows files
> to live under many different classes or categories simultaneously.

I was under the impression that this is what "ln" was for.

How do you go about getting a list of existing classes or categories?
Not of the files within one of them, but of the classes themselves?

> Nest challenge would be to give se() multiple words and it will match
> any file with those strings in it

You've got a basic design problem there, in that "se" as you previously
specified it can already be given multiple words:  it treats two words
as a directory name followed by a file substring.

I take it you want the files that have ALL of the specified words in the
name, in any order, rather than files that have ANY of the words?

ANY of the words is something like:

	se () {
	    setopt localoptions extendedglob noshwordsplit
	    print -l **/(#i)*(${(j:|:)~${(q)*}})*
	} 

ALL of the words, in any order, pretty much requires a loop:

	se () {
	    setopt localoptions extendedglob noshwordsplit
	    local -a possible; possible=( **/(#i)*$1* )
	    shift
	    while (( $# ))
	    do
		possible=( ${(M)possible:#(#i)*$1*} )
		shift
	    done
	    (( $#possible )) && print -l $possible
	} 

Your original question:

> I want to type `draft' at the prompt and press <tab> and then
> get all the options above to show as possible expansions.

I'm going to presume you mean you want this at any place where a file
name would normally be completed.

To accomplish this, you have to create a completer to replace the
supplied `_files' completer.  Something like this:

    _files () {
        local -a possible
        possible=( $(se $words[CURRENT]) )
        if (( $#possible ))
	then
	    compadd -f -U -a -- possible
	else
	    # Copy entire content of supplied _files here
	fi
    }

It's rather too bad that _files doesn't have a _dispatch hook the way
_value and _redirect do ... but even that would apply only in 4.1.x,
not 4.0.x.  

There may be some way to accomplish what you want using a matcher-list
entry, but I haven't been able to work out what it would be.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


      reply	other threads:[~2003-02-23  1:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-12 22:59 Eric Smith
2003-02-13  4:59 ` Bart Schaefer
2003-02-13 14:57   ` Eric Smith
2003-02-23  1:47     ` Bart Schaefer [this message]

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=1030223014730.ZM11489@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@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).