summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorVladimir Kazanov <vekazanov@gmail.com>2024-03-31 18:32:59 +0100
committerMattias EngdegÄrd <mattiase@acm.org>2024-04-01 11:13:12 +0200
commit3f9263f791fb8e4ff0507c8fde95fa19dabcab10 (patch)
treea087989fb07fd830e83d43c9f91e6a8340649926 /lisp/emacs-lisp
parent3f4486dd76c44c76c58605fb9a1643515133ff3f (diff)
downloademacs-3f9263f791fb8e4ff0507c8fde95fa19dabcab10.tar.gz
emacs-3f9263f791fb8e4ff0507c8fde95fa19dabcab10.tar.bz2
emacs-3f9263f791fb8e4ff0507c8fde95fa19dabcab10.zip
Fix symbol list matching regexps.
Fix symbol list matching regexp performance Allow empty face lists, improve the face list matching regexp (see discussion in Bug#69714) based on relint's comments, add tests: * test/lisp/emacs-lisp/ert-font-lock-tests.el: Add tests. * lisp/emacs-lisp/ert-font-lock.el: Fix regexps.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/ert-font-lock.el27
1 files changed, 15 insertions, 12 deletions
diff --git a/lisp/emacs-lisp/ert-font-lock.el b/lisp/emacs-lisp/ert-font-lock.el
index e77c8945dc3..c6fd65e1507 100644
--- a/lisp/emacs-lisp/ert-font-lock.el
+++ b/lisp/emacs-lisp/ert-font-lock.el
@@ -40,31 +40,34 @@
(require 'pcase)
(defconst ert-font-lock--face-symbol-re
- (rx (one-or-more (or alphanumeric "-" "_" ".")))
- "A face symbol matching regex.")
+ (rx (+ (or alphanumeric "-" "_" "." "/")))
+ "A face symbol matching regex.
+The regexp cannot use character classes as these can be redefined by the
+major mode of the host language.")
(defconst ert-font-lock--face-symbol-list-re
(rx "("
(* whitespace)
- (one-or-more
- (seq (regexp ert-font-lock--face-symbol-re)
- (* whitespace)))
+ (? (regexp ert-font-lock--face-symbol-re))
+ (* (+ whitespace)
+ (regexp ert-font-lock--face-symbol-re))
+ (* whitespace)
")")
"A face symbol list matching regex.")
(defconst ert-font-lock--assertion-line-re
(rx
;; leading column assertion (arrow/caret)
- (group (or "^" "<-"))
- (zero-or-more whitespace)
+ (group-n 1 (or "^" "<-"))
+ (* whitespace)
;; possible to have many carets on an assertion line
- (group (zero-or-more (seq "^" (zero-or-more whitespace))))
+ (group-n 2 (* "^" (* whitespace)))
;; optional negation of the face specification
- (group (optional "!"))
- (zero-or-more whitespace)
+ (group-n 3 (optional "!"))
+ (* whitespace)
;; face symbol name or a list of symbols
- (group (or (regexp ert-font-lock--face-symbol-re)
- (regexp ert-font-lock--face-symbol-list-re))))
+ (group-n 4 (or (regexp ert-font-lock--face-symbol-re)
+ (regexp ert-font-lock--face-symbol-list-re))))
"An ert-font-lock assertion line regex.")
(defun ert-font-lock--validate-major-mode (mode)