diff options
author | Ed Santiago <ed@edsantiago.com> | 2020-05-10 07:44:59 -0600 |
---|---|---|
committer | wm4 <1387750+wm4@users.noreply.github.com> | 2020-05-17 12:47:12 +0200 |
commit | 43cb89fca3bdddf4ab3c09618aab38a1d94f8c5c (patch) | |
tree | 128d8bc23763ed35a40efbd689056b794cce1865 /etc/_mpv.zsh | |
parent | 152b0e2a8cb0f3c93de163a39e9c665cb515923f (diff) | |
download | mpv-43cb89fca3bdddf4ab3c09618aab38a1d94f8c5c.tar.bz2 mpv-43cb89fca3bdddf4ab3c09618aab38a1d94f8c5c.tar.xz |
zsh completion: helper functions in private namespace
The generate_xxx() helpers, once defined, would appear as
user-visible functions; this would lead to unexpected and
confusing completion suggestions for gene<tab> after having
once run mpv in that shell.
This PR adds the prefix '_mpv_' to all completion functions
as a convention to make them less user-visible and less likely
to collide with other packages.
Diffstat (limited to 'etc/_mpv.zsh')
-rw-r--r-- | etc/_mpv.zsh | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/etc/_mpv.zsh b/etc/_mpv.zsh index dff2a61629..a15bb7c9ed 100644 --- a/etc/_mpv.zsh +++ b/etc/_mpv.zsh @@ -35,7 +35,7 @@ zstyle -a ":completion:*:*:$service:*" tag-order tag_order || typeset -ga _mpv_completion_arguments _mpv_completion_protocols -function generate_arguments { +function _mpv_generate_arguments { _mpv_completion_arguments=() @@ -143,7 +143,7 @@ function generate_arguments { } -function generate_protocols { +function _mpv_generate_protocols { _mpv_completion_protocols=() local list_protos_line for list_protos_line in "${(@f)$($words[1] --list-protocols)}"; do @@ -153,7 +153,7 @@ function generate_protocols { done } -function generate_if_changed { +function _mpv_generate_if_changed { # Called with $1 = 'arguments' or 'protocols'. Generates the respective list # on the first run and re-generates it if the executable being completed for # is different than the one we used to generate the cached list. @@ -168,7 +168,7 @@ function generate_if_changed { # However, we can't rely on PCRE being available, so we keep all our # patterns POSIX-compatible. zmodload -s -F zsh/pcre C:pcre-match && setopt re_match_pcre - generate_$1 + _mpv_generate_$1 _mpv_completion_binary[$1]=$current_binary fi } @@ -177,7 +177,7 @@ function generate_if_changed { # an option. This way, the user should never see a delay when just completing a # filename. if [[ $words[$CURRENT] == -* ]]; then - generate_if_changed arguments + _mpv_generate_if_changed arguments fi local rc=1 @@ -237,7 +237,7 @@ case $state in if _requested urls; then while _next_label urls expl URL; do _urls "$expl[@]" && rc=0 - generate_if_changed protocols + _mpv_generate_if_changed protocols compadd -S '' "$expl[@]" $_mpv_completion_protocols && rc=0 done fi |