I’m wanting to do basically what this function does. It comes from the zshexpn(1) page and other zsh documentation. I’m trying to “vaguely understand” without diving into the fine details what this function is doing and how it works. In this case, I understand everything more or less except the _wanted line and in particular, is the tag "dynamic-dirs" any arbitrary tag or does it need to match what the higher level driving functions are looking for? I read briefly about tags and it seems like they would need to match up but I can’t find dynamic-dirs anywhere in any code that I’ve grep’ed. Nor have a found any type of list of tags that are used and what they means except the example of “files” and “directories” mentioned in the first few paragraphs of zshcompsys. zsh_directory_name() { emulate -L zsh setopt extendedglob local -a match mbegin mend if [[ $1 = d ]]; then # turn the directory into a name if [[ $2 = (#b)(/home/pws/perforce/)([^/]##)* ]]; then typeset -ga reply reply=(p:$match[2] $(( ${#match[1]} + ${#match[2]} )) ) else return 1 fi elif [[ $1 = n ]]; then # turn the name into a directory [[ $2 != (#b)p:(?*) ]] && return 1 typeset -ga reply reply=(/home/pws/perforce/$match[1]) elif [[ $1 = c ]]; then # complete names local expl local -a dirs dirs=(/home/pws/perforce/*(/:t)) dirs=(p:${^dirs}) _wanted dynamic-dirs expl 'dynamic directory' compadd -S\] -a dirs return else return 1 fi return 0 } The other question is about the ’n’ section. It is going to return a reply even if the directory doesn’t exist. Am I reading the code right? I guess this would be nice if I was going to do `mkdir ~p:foodog` ? Thank you for your time, Perry |
Attachment:
signature.asc
Description: Message signed with OpenPGP