* lisp/font-lock.el (font-lock-regexp-face): New face.
* lisp/progmodes/typescript-ts-mode.el
(typescript-ts-mode--font-lock-settings):
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--font-lock-settings):
* lisp/progmodes/js.el (js--treesit-font-lock-settings):
Use it for regexps.
* etc/NEWS: Mention the addition.
These faces are primarily meant for use with tree-sitter. They are:
'font-lock-bracket-face', 'font-lock-delimiter-face',
'font-lock-escape-face', 'font-lock-number-face',
+'font-lock-regexp-face',
'font-lock-misc-punctuation-face', 'font-lock-operator-face',
'font-lock-property-face', and 'font-lock-punctuation-face'.
"Font Lock mode face used to highlight preprocessor directives."
:group 'font-lock-faces)
+(defface font-lock-regexp-face
+ '((t :inherit font-lock-string-face))
+ "Font Lock mode face used to highlight regexp literals."
+ :group 'font-lock-faces
+ :version "29.1")
+
(defface font-lock-regexp-grouping-backslash
'((t :inherit bold))
"Font Lock mode face for backslashes in Lisp regexp grouping constructs."
:language 'javascript
:feature 'string
- '((regex pattern: (regex_pattern)) @font-lock-string-face
+ '((regex pattern: (regex_pattern)) @font-lock-regexp-face
(string) @font-lock-string-face)
:language 'javascript
;; Also before 'operator because % and / are operators
:language language
:feature 'regexp
- ;; TODO: We probably need a separate face for regexps everywhere.
- ;; Maybe another one for regexp delimiters as well.
- '((regex "/" @font-lock-string-face)
- (regex _ (string_content) @font-lock-string-face))
+ '((regex "/" @font-lock-regexp-face)
+ (regex _ (string_content) @font-lock-regexp-face))
:language language
:feature 'operator
:language language
:override t
:feature 'string
- `((regex pattern: (regex_pattern)) @font-lock-string-face
+ `((regex pattern: (regex_pattern)) @font-lock-regexp-face
(string) @font-lock-string-face
(template_string) @js--fontify-template-string
(template_substitution ["${" "}"] @font-lock-misc-punctuation-face))