From a921c0628ecaa38a40b06280ef89be3e1f64d457 Mon Sep 17 00:00:00 2001 From: Philip Sequeira Date: Tue, 10 Dec 2019 20:59:23 -0500 Subject: 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. --- etc/_mpv.zsh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'etc') 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 -- cgit v1.2.3