(font-lock-regexp-face): New face

* 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.
This commit is contained in:
Dmitry Gutov 2023-01-06 19:56:20 +02:00
parent 5ab03bcc43
commit 2ea6ee5cbf
5 changed files with 11 additions and 6 deletions

View file

@ -798,6 +798,7 @@ filter/sentinel error has been handled.
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'.

View file

@ -2073,6 +2073,12 @@ as the constructs of Haddock, Javadoc and similar systems."
"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."

View file

@ -3498,7 +3498,7 @@ This function is intended for use in `after-change-functions'."
: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

View file

@ -227,10 +227,8 @@ values of OVERRIDE"
;; 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

View file

@ -151,7 +151,7 @@ Argument LANGUAGE is either `typescript' or `tsx'."
: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))