From: Dmitry Gutov Date: Fri, 6 Jan 2023 17:56:20 +0000 (+0200) Subject: (font-lock-regexp-face): New face X-Git-Tag: emacs-29.0.90~820 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2ea6ee5cbfa;p=emacs.git (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. --- diff --git a/etc/NEWS b/etc/NEWS index 059278b08a1..5901b2718e9 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -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'. diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 74881a14ccf..99df8fb9e06 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -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." diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 90b9068fd5d..fe483f220da 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -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 diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index bf09726b34f..5f5de500435 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -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 diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 4042e2b1013..5a9a7eea959 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -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))