From: Dmitry Gutov <dgutov@yandex.ru>
To: Eli Zaretskii <eliz@gnu.org>
Cc: dev@rjt.dev, emacs-devel@gnu.org
Subject: Re: Which face to use for highlighting interpolation delimiters?
Date: Fri, 6 Jan 2023 17:36:57 +0200 [thread overview]
Message-ID: <b4d466e1-aff0-4ec2-818a-9f7ad00612a5@yandex.ru> (raw)
In-Reply-To: <83a62vvipb.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 758 bytes --]
On 06/01/2023 16:30, Eli Zaretskii wrote:
>> Date: Fri, 6 Jan 2023 15:50:02 +0200
>> Cc: emacs-devel<emacs-devel@gnu.org>
>> From: Dmitry Gutov<dgutov@yandex.ru>
>>
>>>> While we're at it, maybe a face for regexp literals as well?
>>> Sure.
>> Eli, could we still add that in emacs-29? We'll make it simply inherit
>> from string and use in a 2-3 ts modes for languages with regexp
>> literals. It's a pretty trivial change.
>>
>> If we defer it until Emacs 30, it will be kinda painful to use in
>> ELPA-distributed packages (e.g. python and hopefully ruby as well).
> In general OK, but please show the patch to add that, so I could know
> exactly what is being proposed.
Sure.
I think these 3 are the only languages we support that have regexp literals.
[-- Attachment #2: font-lock-regexp-face.diff --]
[-- Type: text/x-patch, Size: 2880 bytes --]
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 @@ font-lock-preprocessor-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."
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 @@ js--treesit-font-lock-settings
: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 @@ ruby-ts--font-lock-settings
;; 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 @@ typescript-ts-mode--font-lock-settings
: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))
next prev parent reply other threads:[~2023-01-06 15:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-06 1:53 Which face to use for highlighting interpolation delimiters? Dmitry Gutov
2023-01-06 2:56 ` Randy Taylor
2023-01-06 13:50 ` Dmitry Gutov
2023-01-06 14:30 ` Eli Zaretskii
2023-01-06 15:36 ` Dmitry Gutov [this message]
2023-01-06 16:48 ` Eli Zaretskii
2023-01-06 17:59 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b4d466e1-aff0-4ec2-818a-9f7ad00612a5@yandex.ru \
--to=dgutov@yandex.ru \
--cc=dev@rjt.dev \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.