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

Re: Another keep-prefix problem

On Apr 23,  5:46pm, Wayne Davison wrote:
} Subject: Another keep-prefix problem
} I noticed one other problem with the current zsh (in CVS) and how it
} handles keeping the prefix.  After Bart's last set of tweaks, this
} works:
}    % ls $var1/foo/$var2/bar<TAB>
} But leaving off the leading variable results in a useless expansion:
}    % ls /full/path/foo/$var/bar<TAB>
} When the filename only has an embedded variable, it is expanded.

I suspect this is because of the `suffix' style:

     This is used by the _expand completer if the word starts with a
     tilde or parameter expansion. If it is set to `true', the word will
     only be expanded if it doesn't have a suffix, i.e. if it is
     something like `~foo' or `$foo', but not if it is `~foo/' or
     `$foo/bar', unless that suffix itself contains characters eligible
     for expansion.  The default for this style is `true'.

In your example, $var2 is in the suffix and eligible for expansion, so
expansion is tried, and keep-prefix only preserves the leading $var1 in
that case.

} Here's a (completely usless) failure case:
}    zsh -f
}    % autoload -U compinit
}    % compinit
}    % zstyle ':completion:*' completer _expand _complete
}    % zstyle ':completion:*:expand:*' keep-prefix true
}    % bindkey '\t' complete-word
}    % www=/var/www/html
}    % mkdir $www/subdir
}    % echo ~
}    /home/wayne
}    % ls -l ~/../..$www/sub<TAB>
} ... properly expands to 'subdir' ...

You don't mean "expands", you mean "completes", right?

}    % ls -l /home/wayne/../..$www/sub<TAB>
} ... does not.

Exactly how does it not work?  For me, it expands (not completes) to
`/home/wayne/../../var/www/html/sub' and completion can continue from
there.  keep-prefix only applies to words that begin with `~' or `$',
not to words that have a `$' anywhere in the prefix; the `suffix' style
is for the words with a `$' somewhere else (which is a slight misnomer,
as it means the file-path-suffix of the completion-prefix, and not the
completion-suffix (which is the stuff to the right of the cursor)).

Maybe you want to look at the `subst-globs-only' and/or `substitute'
styles, if you haven't already done so.

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