#compdef more

autoload -U is-at-least

_more() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" : \
'-n+[more-help-lines]:number:_default' \
'--lines=[more-help-lines]:number:_default' \
'--number=[more-help-number]: :_default' \
'-F+[more-help-from-line]:number:_default' \
'--from-line=[more-help-from-line]:number:_default' \
'-P+[more-help-pattern]:pattern:_default' \
'--pattern=[more-help-pattern]:pattern:_default' \
'-d[more-help-silent]' \
'--silent[more-help-silent]' \
'-l[more-help-logical]' \
'--logical[more-help-logical]' \
'-e[more-help-exit-on-eof]' \
'--exit-on-eof[more-help-exit-on-eof]' \
'-f[more-help-no-pause]' \
'--no-pause[more-help-no-pause]' \
'-p[more-help-print-over]' \
'--print-over[more-help-print-over]' \
'-c[more-help-clean-print]' \
'--clean-print[more-help-clean-print]' \
'-s[more-help-squeeze]' \
'--squeeze[more-help-squeeze]' \
'-u[more-help-plain]' \
'--plain[more-help-plain]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'::files -- more-help-files:_files' \
&& ret=0
}

(( $+functions[_more_commands] )) ||
_more_commands() {
    local commands; commands=()
    _describe -t commands 'more commands' commands "$@"
}

if [ "$funcstack[1]" = "_more" ]; then
    _more "$@"
else
    compdef _more more
fi
