emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/consult 05089f0 2/5: Add lookahead wrapper only if ther


From: ELPA Syncer
Subject: [elpa] externals/consult 05089f0 2/5: Add lookahead wrapper only if there is more than one regular expression
Date: Thu, 5 Aug 2021 15:57:09 -0400 (EDT)

branch: externals/consult
commit 05089f0f8e3d7fd0493700076d021c30afb6a582
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]