[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/consult 28c7786 2/4: Minor cleanup
From: |
ELPA Syncer |
Subject: |
[elpa] externals/consult 28c7786 2/4: Minor cleanup |
Date: |
Thu, 5 Aug 2021 13:57:08 -0400 (EDT) |
branch: externals/consult
commit 28c7786d7180024b7e5febd7c3afb59ef51e7729
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Minor cleanup
---
consult.el | 47 +++++++++++++++++++++++------------------------
1 file changed, 23 insertions(+), 24 deletions(-)
diff --git a/consult.el b/consult.el
index ba8069e..9cfc21a 100644
--- a/consult.el
+++ b/consult.el
@@ -551,34 +551,33 @@ ARGS is a list of commands or sources followed by the
list of keyword-value pair
(defun consult--convert-regexp (regexp type)
"Convert Emacs REGEXP to regexp syntax TYPE.
This function only changes the escaping of parentheses, braces and pipes."
- ;; See
https://stackoverflow.com/questions/1946352/comparison-table-for-emacs-regexp-and-perl-compatible-regular-expression-pcre
- ;; XXX Unsupported Emacs regexp features:
- ;; * "*" at the beginning of a choice, e.g, "\(?:*" or "\|*"
- ;; * Backslash constructs \= \sx \Sx \cx \Cx
- (let ((subst `(("\\\\" . "\\\\")
- ,@(if (eq type 'pcre)
- '(("\\`" . "\\\\A") ("\\'" . "\\\\Z")
- ("\\<" . "\\\\b") ("\\>" . "\\\\b")
- ("\\_<" . "\\\\b") ("\\_>" . "\\\\b"))
- '(("\\`" . "\\\\`") ("\\'" . "\\\\'")
- ("\\<" . "\\\\<") ("\\>" . "\\\\>")
- ("\\_<" . "\\\\<") ("\\_>" . "\\\\>"))))))
- (replace-regexp-in-string
- "\\\\\\\\\\|\\\\?[(){}|]\\|\\\\[`'<>]\\|\\\\_[<>]"
- (lambda (x)
- (cond
- ((cdr (assoc x subst)))
- ((= 1 (length x)) (concat "\\\\" x))
- (t (substring x 1))))
- regexp)))
+ (if (memq type '(emacs basic))
+ regexp
+ ;; See
https://stackoverflow.com/questions/1946352/comparison-table-for-emacs-regexp-and-perl-compatible-regular-expression-pcre
+ ;; XXX Unsupported Emacs regexp features:
+ ;; * "*" at the beginning of a choice, e.g, "\(?:*" or "\|*"
+ ;; * Backslash constructs \= \sx \Sx \cx \Cx
+ (let ((subst `(("\\\\" . "\\\\")
+ ,@(if (eq type 'pcre)
+ '(("\\`" . "\\\\A") ("\\'" . "\\\\Z")
+ ("\\<" . "\\\\b") ("\\>" . "\\\\b")
+ ("\\_<" . "\\\\b") ("\\_>" . "\\\\b"))
+ '(("\\`" . "\\\\`") ("\\'" . "\\\\'")
+ ("\\<" . "\\\\<") ("\\>" . "\\\\>")
+ ("\\_<" . "\\\\<") ("\\_>" . "\\\\>"))))))
+ (replace-regexp-in-string
+ "\\\\\\\\\\|\\\\?[(){}|]\\|\\\\[`'<>]\\|\\\\_[<>]"
+ (lambda (x)
+ (cond
+ ((cdr (assoc x subst)))
+ ((= 1 (length x)) (concat "\\\\" x))
+ (t (substring x 1))))
+ regexp))))
(defun consult--compile-regexp (str type)
"Compile STR to a list of regexps of TYPE."
(setq str (split-string str nil 'omit-nulls))
- (pcase-exhaustive type
- ((or 'basic 'emacs) str)
- ((or 'pcre 'extended)
- (mapcar (lambda (x) (consult--convert-regexp x type)) str))))
+ (mapcar (lambda (x) (consult--convert-regexp x type)) str))
(defun consult--join-regexp (str type)
"Compile STR to a regexp joined from multiple regexps of TYPE."