#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[@]}" : \
'-P+[Display file beginning from pattern match]:pattern:_default' \
'--pattern=[Display file beginning from pattern match]:pattern:_default' \
'-F+[Display file beginning from line number]:number:_default' \
'--from-line=[Display file beginning from line number]:number:_default' \
'-n+[The number of lines per screen full]:number:_default' \
'--lines=[The number of lines per screen full]:number:_default' \
'--number=[Same as --lines]: :_default' \
'-c[Do not scroll, display text and clean line ends]' \
'--print-over[Do not scroll, display text and clean line ends]' \
'-d[Display help instead of ringing bell]' \
'--silent[Display help instead of ringing bell]' \
'-p[Do not scroll, clean screen and display text]' \
'--clean-print[Do not scroll, clean screen and display text]' \
'-s[Squeeze multiple blank lines into one]' \
'--squeeze[Squeeze multiple blank lines into one]' \
'-u[]' \
'--plain[]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'::files -- Path to the files to be read:_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
