branch: externals/consult commit 05089f0f8e3d7fd0493700076d021c30afb6a582 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
Add lookahead wrapper only if there is more than one regular expression --- consult.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/consult.el b/consult.el index 3a8adfc..5744308 100644 --- a/consult.el +++ b/consult.el @@ -581,10 +581,11 @@ This function only changes the escaping of parentheses, braces and pipes." (defun consult--join-regexp (str type) "Compile STR to a regexp joined from multiple regexps of TYPE." (setq str (consult--compile-regexp str type)) - (pcase-exhaustive type - ((or 'basic 'emacs 'extended) (string-join str ".*")) - ('pcre (concat "^" (mapconcat (lambda (x) (format "(?=.*%s)" x)) - str ""))))) + ;; Add lookahead wrapper only if there is more than one regular expression + (if (and (eq type 'pcre) (cdr str)) + (concat "^" (mapconcat (lambda (x) (format "(?=.*%s)" x)) + str "")) + (string-join str ".*"))) (defun consult--valid-regexp-p (re) "Return t if regexp RE is valid."