diff options
author | Philip Sequeira <phsequei@gmail.com> | 2019-12-10 20:59:23 -0500 |
---|---|---|
committer | wm4 <1387750+wm4@users.noreply.github.com> | 2019-12-15 14:17:00 +0100 |
commit | a921c0628ecaa38a40b06280ef89be3e1f64d457 (patch) | |
tree | f144d67d639ddebb54195b2755ac619306888c19 /etc | |
parent | 698a6a27473dfd2826b2726ad535764f5ebc2623 (diff) | |
download | mpv-a921c0628ecaa38a40b06280ef89be3e1f64d457.tar.bz2 mpv-a921c0628ecaa38a40b06280ef89be3e1f64d457.tar.xz |
zsh completion: actually make pcre optional
It was supposed to be optional already, but I misunderstood how the
re_match_pcre option worked. If it's set, it will try to use PCRE
matching whether it's available or not (and blow up if it's not). So,
first try to load the module it'll use, and only set the option if that
works.
Fixes #7240.
Diffstat (limited to 'etc')
-rw-r--r-- | etc/_mpv.zsh | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/etc/_mpv.zsh b/etc/_mpv.zsh index 265c20acbf..131a61b51e 100644 --- a/etc/_mpv.zsh +++ b/etc/_mpv.zsh @@ -33,13 +33,6 @@ local -a tag_order zstyle -a ":completion:*:*:$service:*" tag-order tag_order || zstyle ":completion:*:*:$service:*" tag-order '!urls' -# Use PCRE for regular expression matching if possible. This approximately -# halves the execution time of generate_arguments compared to the default POSIX -# regex, which translates to a more responsive first tab press. However, we -# can't rely on PCRE being available, so we keep all our patterns -# POSIX-compatible. -setopt re_match_pcre &>/dev/null - typeset -ga _mpv_completion_arguments _mpv_completion_protocols function generate_arguments { @@ -169,6 +162,12 @@ function generate_if_changed { zmodload -F zsh/stat b:zstat current_binary+=T$(zstat +mtime $current_binary) if [[ $_mpv_completion_binary[$1] != $current_binary ]]; then + # Use PCRE for regular expression matching if possible. This approximately + # halves the execution time of generate_arguments compared to the default + # POSIX regex, which translates to a more responsive first tab press. + # 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_completion_binary[$1]=$current_binary fi |