Skip to content

Commit 46e242b

Browse files
committed
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.
1 parent 8e03f9f commit 46e242b

File tree

1 file changed

+15
-30
lines changed

1 file changed

+15
-30
lines changed

extra/_beet

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,19 @@
22

33
# zsh completion for beets music library manager and MusicBrainz tagger: http://beets.radbox.org/
44

5-
# IMPORTANT: You need to change the $completionsdir variable defined below to point to the directory where your completion files
6-
# are stored.
7-
# It will be very slow the first time you try to complete in a zsh shell (especially if you've enable many plugins),
8-
# but a cache file (_beet_cached) will be created after the first completion which will make subsequent calls much
9-
# faster.
10-
# If you enable new plugins or fields you should update the cache file by deleting it, entering the following commands:
11-
# unfunction _beet
12-
# autoload -z _beet
13-
# and then performing another completion in a new shell.
14-
15-
# If cache file exists, use that
16-
local completionsdir="$HOME/.oh-my-zsh/custom/completions"
17-
local cachefile=$completionsdir/_beet_cached
18-
if [[ -r "$cachefile" ]]; then
19-
source "$cachefile"
20-
_beet "$@"
21-
return
22-
fi
5+
# NOTE: it will be very slow the first time you try to complete in a zsh shell (especially if you've enable many plugins)
6+
# You can make it faster in future by creating a cached version:
7+
# 1) perform a query completion with this file (_beet), e.g. do: beet list artist:"<TAB>
8+
# to create the completion function (takes a few seconds)
9+
# 2) save a copy of the completion function: which _beet > _beet_cached
10+
# 3) save a copy of the query completion function: which _beet_query > _beet_query_cached
11+
# 4) copy the contents of _beet_query_cached to the top of _beet_cached
12+
# 5) copy and paste the _beet_field_values function from _beet to the top of _beet_cached
13+
# 6) add the following line to the top of _beet_cached: #compdef beet
14+
# 7) add the following line to the bottom of _beet_cached: _beet "$@"
15+
# 8) save _beet_cached to your completions directory (e.g. /usr/share/zsh/functions/Completion)
16+
# 9) add the following line to your .zshrc file: compdef _beet_cached beet
17+
# You will need to repeat this proceedure each time you enable new plugins if you want them to complete properly.
2318

2419
# useful: argument to _regex_arguments for matching any word
2520
local matchany=/$'[^\0]##\0'/
@@ -73,7 +68,8 @@ queryelem="_values -S : 'query field (add an extra : to match by regexp)' '::' $
7368
# store call to _values function for completing modify terms (no need to complete field values)
7469
modifyelem="_values -S = 'modify field (replace = with ! to remove field)' $(echo "'${^fields[@]}:: '")"
7570
# Create completion function for queries
76-
_regex_arguments _beet_query "$matchany" \# \( "$matchquery" ":query:query string:$queryelem" \) \( "$matchquery" ":query:query string:$queryelem" \) \#
71+
_regex_arguments _beet_query "$matchany" \# \( "$matchquery" ":query:query string:$queryelem" \) \
72+
\( "$matchquery" ":query:query string:$queryelem" \) \#
7773
# store regexps for completing lists of queries and modifications
7874
local -a query modify
7975
query=( \( "$matchquery" ":query:query string:{_beet_query}" \) \( "$matchquery" ":query:query string:{_beet_query}" \) \# )
@@ -265,17 +261,6 @@ _regex_arguments _beet "$matchany" \( "${globalopts[@]}" \# \) "${subcmds[@]}"
265261
# Set tag-order so that options are completed separately from arguments
266262
zstyle ":completion:${curcontext}:" tag-order '! options'
267263

268-
# Save completion functions to _beet_cached
269-
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
270-
which _beet_field_values >> $cachefile
271-
echo "\n\n" >> $cachefile
272-
which _beet_query >> $cachefile
273-
echo "\n\n" >> $cachefile
274-
which _beet >> $cachefile
275-
echo "\n\n" >> $cachefile
276-
echo zstyle \":completion:\${curcontext}:\" tag-order \'! options\' >> $cachefile
277-
echo "\n\n_beet \"\$@\"\n" >> $cachefile
278-
279264
# Execute the completion function
280265
_beet "$@"
281266

0 commit comments

Comments
 (0)