]> git.eshelyaron.com Git - emacs.git/commitdiff
Translate backslash-saturated regexp to rx
authorMattias Engdegård <mattiase@acm.org>
Thu, 7 Sep 2023 16:06:34 +0000 (18:06 +0200)
committerMattias Engdegård <mattiase@acm.org>
Thu, 7 Sep 2023 16:20:16 +0000 (18:20 +0200)
* lisp/minibuffer.el (minibuffer--regexp-propertize):
The original regexp had 83 backslashes in 147 characters which may be
some kind of record.  This transformation cuts it down to 6, and the
generated regexp string is about 14 % shorter.

lisp/minibuffer.el

index 8c642b15a4d7fbeb3c8c05da56d7abd2d0684055..2120e31775eebb2f153986307e1d33df7ac45320 100644 (file)
@@ -4676,8 +4676,14 @@ and `blink-matching-paren' more user-friendly."
         (remove-text-properties (point-min) (point-max) '(syntax-table nil))
         (goto-char (point-min))
         (while (re-search-forward
-                "\\(\\\\\\\\\\)\\|\\(?:\\(?:\\\\\\)\\(?:\\([(){}]\\)\\|\\(\\[\\)\\|\\(\\]\\)\\)\\)\
-\\|\\(\\[:[a-zA-Z]+:\\]\\)\\|\\(\\[\\)\\|\\(\\]\\)\\|\\([(){}]\\)"
+                (rx (| (group "\\\\")
+                       (: "\\" (| (group (in "(){}"))
+                                  (group "[")
+                                  (group "]")))
+                       (group "[:" (+ (in "A-Za-z")) ":]")
+                       (group "[")
+                       (group "]")
+                       (group (in "(){}"))))
                (point-max) 'noerror)
          (cond
            ((match-beginning 1))                ; \\, skip