zsh-users
 help / color / mirror / code / Atom feed
4ab572894e11bead1b766cc83aa5ed21e44cb759 blob 11699 bytes (raw)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
 
#autoload

# The main loop of the completion code. This is what is called when 
# completion is attempted from the command line.

# Note that this function is parsed before $_comp_setup is evaluated,
# so that it should make conservative assumptions about the setting
# of the various options that affect parsing.

# In case non-standard separators are in use.
local IFS=$' \t\n\0'

# If you want to complete only set or unset options for the unsetopt
# and setopt builtin, un-comment these lines:
#
#   local _options_set _options_unset
#
#   _options_set=(${(k)options[(R)on]})
#   _options_unset=(${(k)options[(R)off]})
#
# This is needed because completion functions may set options locally
# which makes the output of setopt and unsetopt reflect a different
# state than the global one for which you are completing.

eval "$_comp_setup"

local func funcs ret=1 tmp _compskip format nm call match min max i num\
      _completers _completer _completer_num curtag _comp_force_list \
      _matchers _matcher _c_matcher _matcher_num _comp_tags _comp_mesg  \
      mesg str context state state_descr line opt_args val_args \
      curcontext="$curcontext" \
      _last_nmatches=-1 _last_menu_style _def_menu_style _menu_style sel \
      _tags_level=0 \
      _saved_exact="${compstate[exact]}" \
      _saved_lastprompt="${compstate[last_prompt]}" \
      _saved_list="${compstate[list]}" \
      _saved_insert="${compstate[insert]}" \
      _saved_colors="$ZLS_COLORS" \
      _saved_colors_set=${+ZLS_COLORS} \
      _ambiguous_color=''
# Hide any '_comp_priv_prefix' variable that happens to be defined in the calling scope.
local _comp_priv_prefix
unset _comp_priv_prefix

# _precommand sets this to indicate we are following a precommand modifier
local -a precommands

# Precommands which allow their wrapped command to be a builtin.
# All of these are necessarily builtins or reserved words themselves,
# but not all builtin precommands are listed here:
# for one, the 'command' builtin is excluded.
local -ar builtin_precommands=(- builtin eval exec nocorrect noglob time)

typeset -U _lastdescr _comp_ignore _comp_colors

{

[[ -z "$curcontext" ]] && curcontext=:::

zstyle -s ":completion:${curcontext}:" insert-tab tmp || tmp=yes

if [[ ( "$tmp" = *pending(|[[:blank:]]*) && PENDING -gt 0 ) ||
      ( "$tmp" = *pending=(#b)([0-9]##)(|[[:blank:]]*) &&
        PENDING -ge $match[1] ) ]]; then
  compstate[insert]=tab

  return 0
fi

if [[ "$compstate[insert]" = tab* ]]; then
  if [[ "$tmp" = (|*[[:blank:]])(yes|true|on|1)(|[[:blank:]]*) ]]; then
    if [[ "$curcontext" != :* || -z "$compstate[vared]" ]] ||
      zstyle -t ":completion:vared${curcontext}:" insert-tab; then
      return 0
    fi
  fi

  compstate[insert]="${compstate[insert]//tab /}"
fi

# Second attempt at GLOB_COMPLETE

if [[ "$compstate[pattern_match]" = "*" &&
      "$_lastcomp[unambiguous]" = "$PREFIX" &&
      -n "$_lastcomp[unambiguous_cursor]" &&
      "$CURSOR" -eq "$_lastcomp[unambiguous_cursor]" ]]; then
  integer upos="$_lastcomp[unambiguous_cursor]"
  SUFFIX="$PREFIX[upos,-1]$SUFFIX"
  PREFIX="$PREFIX[1,upos-1]"
fi

# Special completion contexts after `~' and `='.

if [[ -z "$compstate[quote]" ]]; then
  if [[ -o equals ]] && compset -P 1 '='; then
    compstate[context]=equal
  elif [[ "$PREFIX" != */* && "$PREFIX[1]" = '~' ]]; then
    if [[ "$PREFIX" = '~['[^\]]# ]]; then
      # Inside ~[...] should be treated as a subscript.
      compset -p 2
      # To be consistent, we ignore all but the contents of the square
      # brackets.
      compset -S '\]*'
      compstate[context]=subscript
      [[ -n $_comps[-subscript-] ]] && $_comps[-subscript-] && return
    else
      compset -p 1
      compstate[context]=tilde
    fi
  fi
fi

# Initial setup.

_setup default
_def_menu_style=( "$_last_menu_style[@]"

# We can't really do that because the current value of $MENUSELECT
# may be the one set by this function.
# There is a similar problem with $ZLS_COLORS in _setup.

#                  ${MENUSELECT+select${MENUSELECT:+\=$MENUSELECT}}

                )
_last_menu_style=()

if zstyle -s ":completion:${curcontext}:default" list-prompt tmp; then
  LISTPROMPT="$tmp"
  zmodload -i zsh/complist
fi
if zstyle -s ":completion:${curcontext}:default" select-prompt tmp; then
  MENUPROMPT="$tmp"
  zmodload -i zsh/complist
fi
if zstyle -s ":completion:${curcontext}:default" select-scroll tmp; then
  MENUSCROLL="$tmp"
  zmodload -i zsh/complist
fi

# Get the names of the completers to use in the positional parameters.

if (( $# )); then
  if [[ "$1" = - ]]; then
    if [[ $# -lt 3 ]]; then
      _completers=()
    else
      _completers=( "$2" )
      call=yes
    fi
  else
    _completers=( "$@" )
  fi
else
  zstyle -a ":completion:${curcontext}:" completer _completers ||
      _completers=( _complete _ignored )
fi

# And now just call the completer functions defined.

_completer_num=1

# We assume localtraps to be in effect here ...
integer SECONDS=0
TRAPINT() {
  zle -M "Killed by signal in ${funcstack[2]} after ${SECONDS}s";
  zle -R
  return 130
}
TRAPQUIT() {
  zle -M "Killed by signal in ${funcstack[2]} after ${SECONDS}s";
  zle -R
  return 131
}

# Call the pre-functions.

funcs=( "$compprefuncs[@]" )
compprefuncs=()
for func in "$funcs[@]"; do
  "$func"
done

for tmp in "$_completers[@]"; do

  if [[ -n "$call" ]]; then
    _completer="${tmp}"
  elif [[ "$tmp" = *:-* ]]; then
    _completer="${${tmp%:*}[2,-1]//_/-}${tmp#*:}"
    tmp="${tmp%:*}"
  elif [[ $tmp = *:* ]]; then
    _completer="${tmp#*:}"
    tmp="${tmp%:*}"
  else
    _completer="${tmp[2,-1]//_/-}"
  fi

  curcontext="${curcontext/:[^:]#:/:${_completer}:}"
  zstyle -t ":completion:${curcontext}:" show-completer &&
    zle -R "Trying completion for :completion:${curcontext}"

  zstyle -a ":completion:${curcontext}:" matcher-list _matchers ||
      _matchers=( '' )

  _matcher_num=1
  _matcher=''
  for _c_matcher in "$_matchers[@]"; do
    if [[ "$_c_matcher" == +* ]]; then
      _matcher="$_matcher $_c_matcher[2,-1]"
    else
      _matcher="$_c_matcher"
    fi

    _comp_mesg=
    if [[ -n "$call" ]]; then
      if "${(@)argv[3,-1]}"; then
        ret=0
        break 2
      fi
    elif "$tmp"; then
      ret=0
      break 2
    fi
    (( _matcher_num++ ))
  done
  [[ -n "$_comp_mesg" ]] && break

  (( _completer_num++ ))
done

curcontext="${curcontext/:[^:]#:/::}"
if [[ $compstate[old_list] = keep ]]; then
  # We are keeping the old list of matches, so keep the
  # number of matches we found last time rather than the
  # number just generated.
  nm=$_lastcomp[nmatches]
else
  nm=$compstate[nmatches]
fi

if [[ $compstate[old_list] = keep || nm -gt 1 ]]; then
  [[ _last_nmatches -ge 0 && _last_nmatches -ne nm ]] &&
      _menu_style=( "$_last_menu_style[@]" "$_menu_style[@]" )

  tmp=$(( compstate[list_lines] + BUFFERLINES + 1 ))

  _menu_style=( "$_menu_style[@]" "$_def_menu_style[@]" )

  if [[ "$compstate[list]" = *list(| *) && tmp -gt LINES &&
        ( -n "$_menu_style[(r)select=long-list]" ||
          -n "$_menu_style[(r)(yes|true|on|1)=long-list]" ) ]]; then
    compstate[insert]=menu
  elif [[ "$compstate[insert]" = "$_saved_insert" ]]; then
    if [[ -n "$compstate[insert]" &&
          -n "$_menu_style[(r)(yes|true|1|on)=long]" && tmp -gt LINES ]]; then
        compstate[insert]=menu
    else
      sel=( "${(@M)_menu_style:#(yes|true|1|on)*}" )

      if (( $#sel )); then
	min=9999999
        for i in "$sel[@]"; do
          if [[ "$i" = *\=[0-9]* ]]; then
  	    num="${i#*\=}"
  	    [[ num -lt 0 ]] && num=0
  	  elif [[ "$i" != *\=* ]]; then
  	    num=0
          else
	    num=9999999
  	  fi
  	  [[ num -lt min ]] && min="$num"
  
	  (( min )) || break
        done
      fi
      sel=( "${(@M)_menu_style:#(no|false|0|off)*}" )

      if (( $#sel )); then
	max=9999999
        for i in "$sel[@]"; do
          if [[ "$i" = *\=[0-9]* ]]; then
  	    num="${i#*\=}"
  	    [[ num -lt 0 ]] && num=0
          elif [[ "$i" != *\=* ]]; then
  	    num=0
  	  else
  	    num=9999999
  	  fi
  	  [[ num -lt max ]] && max="$num"
  
	  (( max )) || break
        done
      fi
      if [[ ( -n "$min" && nm -ge min && ( -z "$max" || nm -lt max ) ) ||
            ( -n "$_menu_style[(r)auto*]" &&
              "$compstate[insert]" = automenu ) ]]; then
        compstate[insert]=menu
      elif [[ -n "$max" && nm -ge max ]]; then
        compstate[insert]=unambiguous
      elif [[ -n "$_menu_style[(r)auto*]" &&
              "$compstate[insert]" != automenu ]]; then
        compstate[insert]=automenu-unambiguous
      fi
    fi
  fi

  if [[ "$compstate[insert]" = *menu* ]]; then
    [[ "$MENUSELECT" = 00 ]] && MENUSELECT=0
    if [[ -n "$_menu_style[(r)no-select*]" ]]; then
      unset MENUSELECT
    elif [[ -n "$_menu_style[(r)select=long*]" ]]; then
      if [[ tmp -gt LINES ]]; then
        zmodload -i zsh/complist
        MENUSELECT=00
      fi
    fi
    if [[ "$MENUSELECT" != 00 ]]; then
      sel=( "${(@M)_menu_style:#select*}" )

      if (( $#sel )); then
	min=9999999
        for i in "$sel[@]"; do
          if [[ "$i" = *\=[0-9]* ]]; then
  	    num="${i#*\=}"
  	    [[ num -lt 0 ]] && num=0
  	  elif [[ "$i" != *\=* ]]; then
  	    num=0
          else
	    num=9999999
  	  fi
  	  [[ num -lt min ]] && min="$num"
  
	  (( min )) || break
        done

        zmodload -i zsh/complist
        MENUSELECT="$min"
      else
        unset MENUSELECT
      fi
    fi
    if [[ -n "$MENUSELECT" ]]; then
      if [[ -n "$_menu_style[(r)interactive*]" ]]; then
        MENUMODE=interactive
      elif [[ -n "$_menu_style[(r)search*]" ]]; then
        if [[ -n "$_menu_style[(r)*backward*]" ]]; then
          MENUMODE=search-backward
        else
          MENUMODE=search-forward
        fi
      else
        unset MENUMODE
      fi
    fi
  fi
elif [[ nm -lt 1 && -n "$_comp_mesg" ]]; then
  compstate[insert]=''
  compstate[list]='list force'
elif [[ nm -eq 0 && -z "$_comp_mesg" &&
        $#_lastdescr -ne 0 && $compstate[old_list] != keep ]] &&
     zstyle -s ":completion:${curcontext}:warnings" format format; then

  compstate[list]='list force'
  compstate[insert]=''

  tmp=( "\`${(@)^_lastdescr:#}'" )

  case $#tmp in
  1) str="$tmp[1]";;
  2) str="$tmp[1] or $tmp[2]";;
  *) str="${(j:, :)tmp[1,-2]}, or $tmp[-1]";;
  esac

  _setup warnings
  zformat -f mesg "$format" "d:$str" "D:${(F)${(@)_lastdescr:#}}"
  compadd -x "$mesg"
fi

if [[ -n "$_ambiguous_color" ]]; then
  local toquote='[=\(\)\|~^?*[\]#<>]'
  local prefix=${${compstate[unambiguous]}[1,${compstate[unambiguous_cursor]}-1]}
  [[ -n $prefix ]] &&
    _comp_colors+=( "=(#i)${prefix[1,-2]//?/(}${prefix[1,-2]//(#m)?/${MATCH/$~toquote/\\$MATCH}|)}${prefix[-1]//(#m)$~toquote/\\$MATCH}(#b)(?|)*==$_ambiguous_color" )
fi

[[ "$_comp_force_list" = always ||
   ( "$_comp_force_list" = ?*  && nm -ge _comp_force_list ) ]] &&
    compstate[list]="${compstate[list]//messages} force"

} always {
  # Stuff we always do to clean up.
  if [[ "$compstate[old_list]" = keep ]]; then
    if [[ $_saved_colors_set = 1 ]]; then
      ZLS_COLORS="$_saved_colors"
    else
      unset ZLS_COLORS
    fi
  elif (( $#_comp_colors )); then
    ZLS_COLORS="${(j.:.)_comp_colors}"
  else
    unset ZLS_COLORS
  fi
}

# Now call the post-functions.

funcs=( "$comppostfuncs[@]" )
comppostfuncs=()
for func in "$funcs[@]"; do
  "$func"
done

_lastcomp=( "${(@kv)compstate}" )
_lastcomp[nmatches]=$nm
_lastcomp[completer]="$_completer"
_lastcomp[prefix]="$PREFIX"
_lastcomp[suffix]="$SUFFIX"
_lastcomp[iprefix]="$IPREFIX"
_lastcomp[isuffix]="$ISUFFIX"
_lastcomp[qiprefix]="$QIPREFIX"
_lastcomp[qisuffix]="$QISUFFIX"
_lastcomp[tags]="$_comp_tags"

return ret
debug log:

solving 4ab572894 ...
found 4ab572894 in https://inbox.vuxu.org/zsh-users/CAH+w=7YBKZyMbBkB+jcu9NvhdLa6OpB_4uohGcJpoYt21vRRaQ@mail.gmail.com/
found 169ca1f40 in https://git.vuxu.org/mirror/zsh/
preparing index
index prepared:
100644 169ca1f40d317903b1fcaebb21616057fd474558	Completion/Base/Core/_main_complete

applying [1/1] https://inbox.vuxu.org/zsh-users/CAH+w=7YBKZyMbBkB+jcu9NvhdLa6OpB_4uohGcJpoYt21vRRaQ@mail.gmail.com/
index 169ca1f40..4ab572894 100644

warning: core.fsyncObjectFiles is deprecated; use core.fsync instead
Checking patch Completion/Base/Core/_main_complete...
Applied patch Completion/Base/Core/_main_complete cleanly.

index at:
100644 4ab572894e11bead1b766cc83aa5ed21e44cb759	Completion/Base/Core/_main_complete

Code repositories for project(s) associated with this inbox:

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).