Roll back zsh completion to 9dc7995

See #2266. The recently introduced caching mechanism is nifty, but it's
causing problems for many users. We're rolling it back until the author can
get to the bottom of the problem.
This commit is contained in:
Adrian Sampson 2016-12-16 21:49:36 -05:00
parent 8e03f9f7b2
commit 46e242b2b9

View file

@ -2,24 +2,19 @@
# zsh completion for beets music library manager and MusicBrainz tagger: http://beets.radbox.org/ # zsh completion for beets music library manager and MusicBrainz tagger: http://beets.radbox.org/
# IMPORTANT: You need to change the $completionsdir variable defined below to point to the directory where your completion files # NOTE: it will be very slow the first time you try to complete in a zsh shell (especially if you've enable many plugins)
# are stored. # You can make it faster in future by creating a cached version:
# It will be very slow the first time you try to complete in a zsh shell (especially if you've enable many plugins), # 1) perform a query completion with this file (_beet), e.g. do: beet list artist:"<TAB>
# but a cache file (_beet_cached) will be created after the first completion which will make subsequent calls much # to create the completion function (takes a few seconds)
# faster. # 2) save a copy of the completion function: which _beet > _beet_cached
# If you enable new plugins or fields you should update the cache file by deleting it, entering the following commands: # 3) save a copy of the query completion function: which _beet_query > _beet_query_cached
# unfunction _beet # 4) copy the contents of _beet_query_cached to the top of _beet_cached
# autoload -z _beet # 5) copy and paste the _beet_field_values function from _beet to the top of _beet_cached
# and then performing another completion in a new shell. # 6) add the following line to the top of _beet_cached: #compdef beet
# 7) add the following line to the bottom of _beet_cached: _beet "$@"
# If cache file exists, use that # 8) save _beet_cached to your completions directory (e.g. /usr/share/zsh/functions/Completion)
local completionsdir="$HOME/.oh-my-zsh/custom/completions" # 9) add the following line to your .zshrc file: compdef _beet_cached beet
local cachefile=$completionsdir/_beet_cached # You will need to repeat this proceedure each time you enable new plugins if you want them to complete properly.
if [[ -r "$cachefile" ]]; then
source "$cachefile"
_beet "$@"
return
fi
# useful: argument to _regex_arguments for matching any word # useful: argument to _regex_arguments for matching any word
local matchany=/$'[^\0]##\0'/ local matchany=/$'[^\0]##\0'/
@ -73,7 +68,8 @@ queryelem="_values -S : 'query field (add an extra : to match by regexp)' '::' $
# store call to _values function for completing modify terms (no need to complete field values) # store call to _values function for completing modify terms (no need to complete field values)
modifyelem="_values -S = 'modify field (replace = with ! to remove field)' $(echo "'${^fields[@]}:: '")" modifyelem="_values -S = 'modify field (replace = with ! to remove field)' $(echo "'${^fields[@]}:: '")"
# Create completion function for queries # Create completion function for queries
_regex_arguments _beet_query "$matchany" \# \( "$matchquery" ":query:query string:$queryelem" \) \( "$matchquery" ":query:query string:$queryelem" \) \# _regex_arguments _beet_query "$matchany" \# \( "$matchquery" ":query:query string:$queryelem" \) \
\( "$matchquery" ":query:query string:$queryelem" \) \#
# store regexps for completing lists of queries and modifications # store regexps for completing lists of queries and modifications
local -a query modify local -a query modify
query=( \( "$matchquery" ":query:query string:{_beet_query}" \) \( "$matchquery" ":query:query string:{_beet_query}" \) \# ) query=( \( "$matchquery" ":query:query string:{_beet_query}" \) \( "$matchquery" ":query:query string:{_beet_query}" \) \# )
@ -265,17 +261,6 @@ _regex_arguments _beet "$matchany" \( "${globalopts[@]}" \# \) "${subcmds[@]}"
# Set tag-order so that options are completed separately from arguments # Set tag-order so that options are completed separately from arguments
zstyle ":completion:${curcontext}:" tag-order '! options' zstyle ":completion:${curcontext}:" tag-order '! options'
# Save completion functions to _beet_cached
echo "# Cached completion file for beet\n# Note: this was created from _beet, and should be regenerated when new fields or plugins are added.\n# To regenerate this file just delete it, open a new zshell and try completing beet.\n\n" > $cachefile
which _beet_field_values >> $cachefile
echo "\n\n" >> $cachefile
which _beet_query >> $cachefile
echo "\n\n" >> $cachefile
which _beet >> $cachefile
echo "\n\n" >> $cachefile
echo zstyle \":completion:\${curcontext}:\" tag-order \'! options\' >> $cachefile
echo "\n\n_beet \"\$@\"\n" >> $cachefile
# Execute the completion function # Execute the completion function
_beet "$@" _beet "$@"