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

Re: echo-ing case insensitively



[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   



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