Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: modifiers with _expand and keep-prefix
- X-seq: zsh-workers 20236
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxxxxx>
- Subject: PATCH: modifiers with _expand and keep-prefix
- Date: Sat, 07 Aug 2004 16:58:59 +0200
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
With the keep-prefix style set, if a modifier in an expansion has the
effect of removing or changing the prefix, _expand adds it back. For
example:
% echo ~/.z*(:t)<tab>
expands to:
% echo ~.zcompdump ~.zfunc ~.zshenv ...
Fix is below. I check whether ${exp[1]} starts with $pre. Before
allowing the code which does exp=( ${opre}${^exp#${pre}} ). Makes sense
to check that the old prefix can be removed before adding the old.
Strictly speaking the test should be something like:
[[ -z $exp[(r)$pre*] ]]
but we already have a test which assumes that what is right for
${exp[1]} is right for the rest of the array.
Oliver
Index: Completion/Base/Completer/_expand
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Completer/_expand,v
retrieving revision 1.8
diff -u -r1.8 _expand
--- Completion/Base/Completer/_expand 7 Jul 2003 09:48:46 -0000 1.8
+++ Completion/Base/Completer/_expand 7 Aug 2004 14:40:36 -0000
@@ -133,8 +133,9 @@
if [[ -n "$epre" && $#epre -eq 1 ]]; then
pre="${(q)epre[1]}"
- [[ "$tmp" != changed || $#exp -gt 1 ||
- "${opre}${exp[1]#${pre}}" != "$word" ]] && exp=( ${opre}${^exp#${pre}} )
+ [[ ( "$tmp" != changed || $#exp -gt 1 ||
+ "${opre}${exp[1]#${pre}}" != "$word" ) && "${exp[1]}" = $pre* ]] &&
+ exp=( ${opre}${^exp#${pre}} )
fi
[[ $#exp -eq 1 && "$exp[1]" = "$word" ]] && return 1
fi
Messages sorted by:
Reverse Date,
Date,
Thread,
Author