From 43cb89fca3bdddf4ab3c09618aab38a1d94f8c5c Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Sun, 10 May 2020 07:44:59 -0600 Subject: 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 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. --- etc/_mpv.zsh | 12 ++++++------ 1 file 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 -- cgit v1.2.3