#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+[The number of lines per screen full]:number:_default' \
'--lines=[The number of lines per screen full]:number:_default' \
'--number=[Same as --lines option argument]: :_default' \
'-F+[Start displaying each file at line number]:number:_default' \
'--from-line=[Start displaying each file at line number]:number:_default' \
'-P+[The string to be searched in each file before starting to display it]:pattern:_default' \
'--pattern=[The string to be searched in each file before starting to display it]:pattern:_default' \
'-d[Display help instead of ringing bell when an illegal key is pressed]' \
'--silent[Display help instead of ringing bell when an illegal key is pressed]' \
'-l[Do not pause after any line containing a ^L (form feed)]' \
'--logical[Do not pause after any line containing a ^L (form feed)]' \
'-e[Exit on End-Of-File]' \
'--exit-on-eof[Exit on End-Of-File]' \
'-f[Count logical lines, rather than screen lines]' \
'--no-pause[Count logical lines, rather than screen lines]' \
'-p[Do not scroll, clear screen and display text]' \
'--print-over[Do not scroll, clear screen and display text]' \
'-c[Do not scroll, display text and clean line ends]' \
'--clean-print[Do not scroll, display text and clean line ends]' \
'-s[Squeeze multiple blank lines into one]' \
'--squeeze[Squeeze multiple blank lines into one]' \
'-u[Suppress underlining]' \
'--plain[Suppress underlining]' \
'-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
