Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] _parameters: complete namespace only after ${
- X-seq: zsh-workers 54251
- From: Jun T <takimoto-j@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] _parameters: complete namespace only after ${
- Date: Thu, 26 Mar 2026 16:56:27 +0900
- Archived-at: <https://zsh.org/workers/54251>
- List-id: <zsh-workers.zsh.org>
Parameter names like .foo.bar (or just .foo or foo.) are
allowed only inside ${...}. But
% echo $.t<TAB>
gives $.term.bg etc. The patch below fixes this problem,
BUT there is another problem:
% echo ${.<TAB>
gives nothing either with or without the patch. I will
discuss this in another post.
diff --git a/Completion/Zsh/Type/_parameters b/Completion/Zsh/Type/_parameters
index d3893a942..d92197b42 100644
--- a/Completion/Zsh/Type/_parameters
+++ b/Completion/Zsh/Type/_parameters
@@ -10,15 +10,19 @@ local i pfilt
local -i nm=$compstate[nmatches]
local -a expl pattern=( -g \* ) normal described verbose faked fakes tmp
+# parameter names that match the pattern $pfilt are removed
zstyle -t ":completion:${curcontext}:parameters" prefix-needed &&
[[ $PREFIX != [_.]* ]] &&
- pfilt='[^_.]'
+ pfilt='[_.]*'
+# names containing a dot are allowed only within ${ }
+[[ $IPREFIX != \${* ]] && pfilt+='|*.*'
+
_description parameters expl parameter
zparseopts -D -K -E g:=pattern
if zstyle -t ":completion:${curcontext}:parameters" extra-verbose; then
described=(
- "${(@M)${(@k)parameters[(R)$~pattern[2]~*(hideval|local|special)*]}:#$~pfilt*}"
+ ${(k)parameters[(R)$~pattern[2]~*(hideval|local|special)*]:#$~pfilt}
)
compadd "$@" "$expl[@]" -D described -a - described
if (( $#described )); then
@@ -33,10 +37,10 @@ if zstyle -t ":completion:${curcontext}:parameters" extra-verbose; then
fi
normal=(
- "${(@M)${(@k)parameters[(R)$~pattern[2]~^(*(hideval|special)*)~*local*]}:#$~pfilt*}"
+ ${(k)parameters[(R)$~pattern[2]~^(*(hideval|special)*)~*local*]:#$~pfilt}
)
else
- normal=( "${(@M)${(@k)parameters[(R)$~pattern[2]~*local*]}:#$~pfilt*}" )
+ normal=( ${(k)parameters[(R)${~pattern[2]}~*local*]:#$~pfilt} )
fi
if zstyle -a ":completion:${curcontext}:" fake-parameters tmp; then
Messages sorted by:
Reverse Date,
Date,
Thread,
Author