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

Re: help with _match, globcomplete etc. (with a PATCH)



On Feb 16, 10:38am, Oliver Kiddle wrote:
} Subject: Re: help with _match, globcomplete etc. (with a PATCH)
}
} The reason I wanted this is basically that I use a number of associative
} arrays to point to different areas of the system I work on. [...]
} 
} [...] This leads me to make a suggestion which may or may not be easy
} but would solve my problems: in the same way as a variable whose
} value is a directory can be refered to with ~, could the same be made
} to work for associative arrays (and arrays in general I suppose),
} allowing me to use stuff like ~code[ai] and ~test[$area]?

Hrm.  You can already manually stuff things into the nameddir hash:

zagzig% unsetopt glob
zagzig% typeset -A xx 
zagzig% xx=($(print -l $path | cat -n))
zagzig% echo $xx[9]
/usr/etc
zagzig% for x in ${(k)xx}; hash -d xx[$x]=$xx[$x]
zagzig% cd ~xx[9]<TAB>
zagzig% cd ~xx[9]/

Well, would you look at that.  But if there I press return, I get:

cd: no such file or directory: ~xx[9]

That's because the [ and ] are tokenized most of the time, so they don't
match what has been added to the hash even if the typtab is modified to
treat them as IUSER.  It's probably an accident that the trailing slash
gets added that first time; you can't complete any further after it.

So it may be possible to make this work by using a more sophisticated
parse than simply scanning past all the IUSER characters, and then
throwing in a few calls to untokenize(); but I don't think I'm going to
attempt it.

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



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