[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/consult 894f678 1/2: Improve converter
From: |
ELPA Syncer |
Subject: |
[elpa] externals/consult 894f678 1/2: Improve converter |
Date: |
Thu, 5 Aug 2021 18:57:08 -0400 (EDT) |
branch: externals/consult
commit 894f678c0c5985e349e639f0c491612f4eb08c39
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Improve converter
---
consult.el | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/consult.el b/consult.el
index 4c369cf..b63c70c 100644
--- a/consult.el
+++ b/consult.el
@@ -569,28 +569,26 @@ This function only changes the escaping of parentheses,
braces and pipes."
;; Treat \` and \' as beginning and end of line. This is more
;; widely supported and makes sense for line-based commands.
'(("\\`" . "^") ("\\'" . "$"))
- ;; Question mark at the beginning is supported by Emacs regexps
- '(("?" . "\\?") ("\\|?" . "|\\?"))
- ;; Star and plus at beginning is supported by Emacs regexps
+ ;; Historical: Unescaped *, +, ? are supported at the beginning
(mapcan (lambda (x)
(mapcar (lambda (y)
(cons (concat x y)
(concat (string-remove-prefix "\\" x)
"\\" y)))
- '("*" "+")))
- '("" "\\(" "\\(?:" "\\|"))
+ '("*" "+" "?")))
+ '("" "\\(" "\\(?:" "\\|" "^"))
;; Different escaping
(mapcan (lambda (x) `(,x (,(cdr x) . ,(car x))))
'(("\\|" . "|")
("\\(" . "(") ("\\)" . ")")
("\\{" . "{") ("\\}" . "}"))))))))
(replace-regexp-in-string
- (rx (or (seq "\\" (or "(?:" "(" "|") (any "*+")) ;; \(+ or \(?:* etc
- (seq bos (any "*+")) ;; + or * at the
beginning
- (seq bos "?") "\\|?" ;; \|? or ? at the
beginning
- "\\\\" ;; backslash
- (seq (opt "\\") (any "(){|}")) ;; parens/braces/pipe
- (seq "\\" (any "'<>`")) ;; special escapes
- (seq "\\_" (any "<>")))) ;; beginning/end of
symbol
+ (rx (or "\\\\" "\\^" ;; Pass through
+ (seq (or "\\(?:" "\\|") (any "*+?")) ;; Historical: \|+ or
\(?:* etc
+ (seq "\\(" (any "*+")) ;; Historical: \(* or \(+
+ (seq (or bos "^") (any "*+?")) ;; Historical: + or * at
the beginning
+ (seq (opt "\\") (any "(){|}")) ;; Escape
parens/braces/pipe
+ (seq "\\" (any "'<>`")) ;; Special escapes
+ (seq "\\_" (any "<>")))) ;; Beginning or end of
symbol
(lambda (x) (or (cdr (assoc x subst)) x))
regexp 'fixedcase 'literal))))