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

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

[elpa] externals/consult 3d8cc22 2/4: Simplify


From: ELPA Syncer
Subject: [elpa] externals/consult 3d8cc22 2/4: Simplify
Date: Thu, 5 Aug 2021 17:57:07 -0400 (EDT)

branch: externals/consult
commit 3d8cc225be47441d719c571be808ef6842e60915
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Simplify
---
 consult.el | 44 +++++++++++++++++++++++---------------------
 1 file changed, 23 insertions(+), 21 deletions(-)

diff --git a/consult.el b/consult.el
index c9d7b5f..be6bdb0 100644
--- a/consult.el
+++ b/consult.el
@@ -558,25 +558,28 @@ This function only changes the escaping of parentheses, 
braces and pipes."
     ;; - \= point matching
     ;; - Syntax classes \sx \Sx
     ;; - Character classes \cx \Cx
-    (let ((swap '(("\\|" . "|")
-                  ("\\(" . "(") ("\\)" . ")")
-                  ("\\{" . "{") ("\\}" . "}")))
-          (subst (append
-                  ;; Treat \` and \' as beginning and end of line. This is more
-                  ;; widely supported and makes sense for line-based commands.
-                  '(("\\`" . "^") ("\\'" . "$"))
-                  ;; Star and plus at beginning is supported by Emacs regexps
-                  (mapcan (lambda (x)
-                            (mapcar (lambda (y)
-                                      (cons (concat x y)
-                                            (concat (string-remove-prefix "\\" 
x) "\\" y)))
-                                    '("*" "+")))
-                          '("" "\\(" "\\(?:" "\\|"))
-                  ;; Word beginning/end replacements
-                  (if (memq type '(pcre rust))
-                      '(("\\<" . "\\b") ("\\>" . "\\b")
-                        ("\\_<" . "\\b") ("\\_>" . "\\b"))
-                    '(("\\_<" . "\\<") ("\\_>" . "\\>"))))))
+    (let ((subst
+           (append
+            ;; Different escaping
+            (mapcan (lambda (x) `(,x (,(cdr x) . ,(car x))))
+                    '(("\\|" . "|")
+                      ("\\(" . "(") ("\\)" . ")")
+                      ("\\{" . "{") ("\\}" . "}")))
+            ;; Treat \` and \' as beginning and end of line. This is more
+            ;; widely supported and makes sense for line-based commands.
+            '(("\\`" . "^") ("\\'" . "$"))
+            ;; Star and plus at beginning is supported by Emacs regexps
+            (mapcan (lambda (x)
+                      (mapcar (lambda (y)
+                                (cons (concat x y)
+                                      (concat (string-remove-prefix "\\" x) 
"\\" y)))
+                              '("*" "+")))
+                    '("" "\\(" "\\(?:" "\\|"))
+            ;; Word beginning/end replacements
+            (if (memq type '(pcre rust))
+                '(("\\<" . "\\b") ("\\>" . "\\b")
+                  ("\\_<" . "\\b") ("\\_>" . "\\b"))
+              '(("\\_<" . "\\<") ("\\_>" . "\\>"))))))
       (replace-regexp-in-string
        (string-join
         '("\\\\\\(?:(\\|(\\?:\\||\\)[+*]" ;; (+ or (?:* etc
@@ -586,8 +589,7 @@ This function only changes the escaping of parentheses, 
braces and pipes."
           "\\\\[`'<>]"                    ;; special escapes
           "\\\\_[<>]")                    ;; beginning/end of symbol
         "\\|")
-       (lambda (x)
-         (or (cdr (assoc x subst)) (cdr (assoc x swap)) (car (rassoc x swap)) 
x))
+       (lambda (x) (or (cdr (assoc x subst)) x))
        regexp 'fixedcase 'literal))))
 
 (defun consult--compile-regexp (str type)



reply via email to

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