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.
This commit is contained in:
parent
3f4486dd76
commit
3f9263f791
2 changed files with 60 additions and 14 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue