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

Re: PATCH: Re: Questions/comments on completion code that arise from PWS's zsh guide



Alexandre Duret-Lutz wrote:

>  Sven> The patch adds _tilde_files which completes files and expands tildes
>  Sven> if there are any. And makes _dd use it. 
> 
> But this will *always* expand tildes.  Since I am using magicequalsubst, 
> I don't want tildes to be expanded 'on the line' in places where
> it would be done by magicequalsubst.
> 
> Shouldn't there be a option to _tilde_files saying that _tilde_files is
> called in a context where magicequalsubst will expand the tilde (in which
> case _tilde_files should care whether the magicequalsubst is set or not) ?
> Or it may be the default.

Yes, I think _tilde_files should do that always.

>  Sven> Does anyone know of other places where this might be useful?
> 
> What happens with _arguments's equal-ended options ?
> Should they use _tilde_files instead of _files ?
> It may be good that `--prefix=~/usr' get expanded to
> `--prefix=/myhomedir/usr' when magicequalsubst is unset, 
> but I would find strange that `--prefix ~/usr' expands 
> to `--prefix /myhomedir/usr' too...

Hm. Maybe, but not unconditionally because currently _tilde_files
always does the expansion, not only if there is a $IPREFIX.
The solution would be an option for _tilde_files that makes it do
expansion only if the is a IPREFIX (or maybe an option with an argument 
which is taken as a pattern and _tilde_files expands only if IPREFIX
matches that) and changing the actions in the calls to _arguments and
_values (unless the commands do tilde-expansion themselves).


Bye
 Sven

diff -ru ../z.old/Completion/User/_tilde_files Completion/User/_tilde_files
--- ../z.old/Completion/User/_tilde_files	Fri Feb 25 14:17:37 2000
+++ Completion/User/_tilde_files	Fri Feb 25 16:37:57 2000
@@ -2,7 +2,7 @@
 
 # Complete files and expand tilde expansions in it.
 
-if (( $argv[(I)-W*] )); then
+if [[ ( -o magicequalsubst && "$IPREFIX" = *\= ) || $argv[(I)-W*] -ne 0 ]]; then
   _files "$@"
   return
 fi

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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