summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordana <dana@dana.is>2026-07-08 15:45:30 -0500
committerdana <dana@dana.is>2026-07-08 15:45:33 -0500
commit9b94d374bb787342ab8143f17c7ffa0e324c6255 (patch)
tree6df7cabd2e4a8fbbbb4a5cd4f6dc34e814259e72
parent54913: _numbers: pass -r and -R to compadd (diff)
downloadzsh-9b94d374bb787342ab8143f17c7ffa0e324c6255.tar
zsh-9b94d374bb787342ab8143f17c7ffa0e324c6255.tar.gz
zsh-9b94d374bb787342ab8143f17c7ffa0e324c6255.tar.bz2
zsh-9b94d374bb787342ab8143f17c7ffa0e324c6255.tar.lz
zsh-9b94d374bb787342ab8143f17c7ffa0e324c6255.tar.xz
zsh-9b94d374bb787342ab8143f17c7ffa0e324c6255.tar.zst
zsh-9b94d374bb787342ab8143f17c7ffa0e324c6255.zip
54913: _message: improve option parsing
-rw-r--r--ChangeLog3
-rw-r--r--Completion/Base/Core/_message26
-rw-r--r--Test/Y01completion.ztst14
3 files changed, 31 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 131ada6a8..42965e994 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2026-07-08 dana <dana@dana.is>
+ * 54913: Completion/Base/Core/_message,
+ Test/Y01completion.ztst: improve option parsing
+
* 54913: Completion/Base/Utility/_numbers: pass -r and -R to
compadd
diff --git a/Completion/Base/Core/_message b/Completion/Base/Core/_message
index b80aa4237..8c3f351f6 100644
--- a/Completion/Base/Core/_message
+++ b/Completion/Base/Core/_message
@@ -1,19 +1,26 @@
#autoload
-local format raw gopt
+local format raw
+local -a gopt
+local -A opth
-if [[ "$1" = -e ]]; then
+zparseopts -A opth -D -F - \
+ {1+,2+,V+:,J+:}=gopt F: M: n o: q s: S: x: X: \
+ e r \
+|| return
+
+if (( $+opth[-e] )); then
local expl ret=1 tag
_comp_mesg=yes
- if (( $# > 2 )); then
- tag="$2"
+ if (( $# > 1 )); then
+ tag=$1
shift
else
tag="$curtag"
fi
- _tags "$tag" && while _next_label "$tag" expl "$2"; do
+ _tags "$tag" && while _next_label "$tag" expl "$1"; do
compadd ${expl:/-X/-x}
ret=0
done
@@ -24,15 +31,10 @@ if [[ "$1" = -e ]]; then
return ret
fi
-gopt=()
-zparseopts -D -a gopt 1 2 V J
-
_tags messages || return 1
-if [[ "$1" = -r ]]; then
- raw=yes
- shift
- format="$1"
+if (( $+opth[-r] )); then
+ raw=yes format=$1
else
zstyle -s ":completion:${curcontext}:messages" format format ||
zstyle -s ":completion:${curcontext}:descriptions" format format
diff --git a/Test/Y01completion.ztst b/Test/Y01completion.ztst
index f6e0d2133..57cac2883 100644
--- a/Test/Y01completion.ztst
+++ b/Test/Y01completion.ztst
@@ -424,6 +424,20 @@ F:regression test workers/31611
>line: {tst }{}
>MESSAGE:{%foo %BAR}
+ comptesteval '_tst() { _message -e abc }'
+ comptest $'tst \t'
+ comptesteval '_tst() { _message -e - abc }'
+ comptest $'tst \t'
+ comptesteval '_tst() { _message -e - tag abc }'
+ comptest $'tst \t'
+0:_message -e
+>line: {tst }{}
+>DESCRIPTION:{abc}
+>line: {tst }{}
+>DESCRIPTION:{abc}
+>line: {tst }{}
+>DESCRIPTION:{abc}
+
%clean
zmodload -ui zsh/zpty