Completions are nothing more than auto-loadable functions prefixed with an underscore placed somewhere in $FPATH.