26763: fix problem on failed cd -s to relative path
[zsh.git] / Completion / Base / Core / _message
blob13c83989f06661bb167b91a65bd3a3458712e2f6
1 #autoload
3 local format raw gopt
5 if [[ "$1" = -e ]]; then
6   local expl ret=1 tag
8   _comp_mesg=yes
10   if (( $# > 2 )); then
11     tag="$2"
12     shift
13   else
14     tag="$curtag"
15   fi
16   _tags "$tag" && while _next_label "$tag" expl "$2"; do
17     compadd ${expl:/-X/-x}
18     ret=0
19   done
21   (( $compstate[nmatches] )) || compstate[insert]=
23   return ret
26 gopt=()
27 zparseopts -D -a gopt 1 2 V J
29 _tags messages || return 1
31 if [[ "$1" = -r ]]; then
32   raw=yes
33   shift
34   format="$1"
35 else
36   zstyle -s ":completion:${curcontext}:messages" format format ||
37       zstyle -s ":completion:${curcontext}:descriptions" format format
40 if [[ -n "$format$raw" ]]; then
41   [[ -z "$raw" ]] && zformat -f format "$format" "d:$1" "${(@)argv[2,-1]}"
42   builtin compadd "$gopt[@]" -x "$format"
43   _comp_mesg=yes