From: Randy Taylor <dev@rjt.dev>
To: Eli Zaretskii <eliz@gnu.org>
Cc: casouri@gmail.com, 58940@debbugs.gnu.org
Subject: bug#58940: [PATCH] feature/tree-sitter: Add more font lock faces
Date: Sat, 05 Nov 2022 02:46:30 +0000 [thread overview]
Message-ID: <8ZKenedKBW2xqbSe_c0vWmeRbMQYCDlwFNvSMAYx9utQYeOKPHQQ-nKW9Y8nCcKRnFMmsnfonvA_0yixtSArBzVY_PkaNxxGWqhXoHjCZTo=@rjt.dev> (raw)
In-Reply-To: <835yfxbkyy.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 821 bytes --]
On Wednesday, November 2nd, 2022 at 08:27, Eli Zaretskii <eliz@gnu.org> wrote:
>
> The names are too wordy, IMO. If we want the above, I suggest
>
> font-lock-delimiter-face
> font-lock-bracket-face
> font-lock-misc-punctuation-face
Sorry for the delay, furniture building took longer than anticipated
and desired.
New changes:
- Finally remembered to add Bug# to commit message.
- Made font-lock-escape-face inherit from
font-lock-regexp-grouping-backslash per Dmitry's suggestion.
- Added font-lock-{bracket,delimiter,misc-punctuation}-faces
inheriting from font-lock-punctuation-face.
With the use of tree-sitter features for syntax highlighting
(i.e. specifying specific highlight capabilities), how do we see
punctuation being used? Just a 'punctuation feature that includes
everything?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-more-font-lock-faces-Bug-58940.patch --]
[-- Type: text/x-patch; name=0001-Add-more-font-lock-faces-Bug-58940.patch, Size: 7680 bytes --]
From e8237990037625b0c937b1fa5486c811c64d3d16 Mon Sep 17 00:00:00 2001
From: Randy Taylor <dev@rjt.dev>
Date: Fri, 28 Oct 2022 22:39:50 -0400
Subject: [PATCH] Add more font-lock faces (Bug#58940)
* lisp/font-lock.el (font-lock-bracket-face, font-lock-delimiter-face,
font-lock-escape-face, font-lock-number-face,
font-lock-misc-punctuation-face, font-lock-operator-face,
font-lock-property-face, font-lock-punctuation-face): Define new
faces.
* lisp/cus-theme.el (custom-theme--listed-faces): Add them to the
list.
* doc/lispref/modes.texi (Faces for Font Lock): Document them.
* etc/NEWS: Mention them.
---
doc/lispref/modes.texi | 54 +++++++++++++++++++++++++++++++
etc/NEWS | 7 ++++
lisp/cus-theme.el | 16 ++++++----
lisp/font-lock.el | 72 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 143 insertions(+), 6 deletions(-)
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index c1b092247b..290bd5075e 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -3653,6 +3653,60 @@ Faces for Font Lock
@item font-lock-negation-char-face
@vindex font-lock-negation-char-face
for easily-overlooked negation characters.
+
+@item font-lock-bracket-face
+@vindex font-lock-bracket-face
+for brackets (e.g. @code{()}, @code{[]}, @code{@{@}}).
+This face inherits, by default, from @code{font-lock-punctuation-face}.
+
+@item font-lock-delimiter-face
+@vindex font-lock-delimiter-face
+for delimiters (e.g. @code{;}, @code{:}, @code{,}).
+This face inherits, by default, from @code{font-lock-punctuation-face}.
+
+@item font-lock-escape-face
+@vindex font-lock-escape-face
+for escape sequences in strings.
+This face inherits, by default, from @code{font-lock-regexp-grouping-backslash}.
+
+@item font-lock-number-face
+@vindex font-lock-number-face
+for numbers.
+
+@item font-lock-misc-punctuation-face
+@vindex font-lock-misc-punctuation-face
+for punctuation that is not a bracket or delimiter.
+
+@item font-lock-operator-face
+@vindex font-lock-operator-face
+for operators.
+
+@item font-lock-property-face
+@vindex font-lock-property-face
+for properties of an object, such as the declaration and use of fields
+in a struct.
+This face inherits, by default, from @code{font-lock-variable-name-face}.
+
+For example,
+
+@smallexample
+typedef struct
+@{
+ int prop;
+// ^ property
+@} obj;
+
+int main()
+@{
+ obj o;
+ o.prop = 3;
+// ^ property
+@}
+@end smallexample
+
+@item font-lock-punctuation-face
+@vindex font-lock-punctuation-face
+for punctuation such as brackets and delimiters.
@end table
@node Syntactic Font Lock
diff --git a/etc/NEWS b/etc/NEWS
index c5a142b500..6cf92bdcca 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -732,6 +732,13 @@ If the current buffer is visiting a file that is executable, the
This determines how long to pause Emacs after a process
filter/sentinel error has been handled.
++++
+** New faces for font-lock.
+'font-lock-bracket-face', 'font-lock-delimiter-face',
+'font-lock-escape-face', 'font-lock-number-face',
+'font-lock-misc-punctuation-face', 'font-lock-operator-face',
+'font-lock-property-face', 'font-lock-punctuation-face'.
+
+++
** New face 'variable-pitch-text'.
This face is like 'variable-pitch' (from which it inherits), but is
diff --git a/lisp/cus-theme.el b/lisp/cus-theme.el
index 90680ff68f..1df2ab8db7 100644
--- a/lisp/cus-theme.el
+++ b/lisp/cus-theme.el
@@ -66,13 +66,17 @@ custom-theme--listed-faces
variable-pitch escape-glyph homoglyph
minibuffer-prompt highlight region
shadow secondary-selection trailing-whitespace
- font-lock-builtin-face font-lock-comment-delimiter-face
- font-lock-comment-face font-lock-constant-face
- font-lock-doc-face font-lock-doc-markup-face font-lock-function-name-face
+ font-lock-bracket-face font-lock-builtin-face
+ font-lock-comment-delimiter-face font-lock-comment-face
+ font-lock-constant-face font-lock-delimiter-face
+ font-lock-doc-face font-lock-doc-markup-face
+ font-lock-escape-face font-lock-function-name-face
font-lock-keyword-face font-lock-negation-char-face
- font-lock-preprocessor-face font-lock-regexp-grouping-backslash
- font-lock-regexp-grouping-construct font-lock-string-face
- font-lock-type-face font-lock-variable-name-face
+ font-lock-number-face font-lock-misc-punctuation-face
+ font-lock-operator-face font-lock-preprocessor-face
+ font-lock-property-face font-lock-punctuation-face
+ font-lock-regexp-grouping-backslash font-lock-regexp-grouping-construct
+ font-lock-string-face font-lock-type-face font-lock-variable-name-face
font-lock-warning-face button link link-visited fringe
header-line tooltip mode-line mode-line-buffer-id
mode-line-emphasis mode-line-highlight mode-line-inactive
diff --git a/lisp/font-lock.el b/lisp/font-lock.el
index e88dc1d3b7..b79d578848 100644
--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -359,6 +359,30 @@ font-lock-negation-char-face
(defvar font-lock-preprocessor-face 'font-lock-preprocessor-face
"Face name to use for preprocessor directives.")
+(defvar font-lock-bracket-face 'font-lock-bracket-face
+ "Face name to use for brackets.")
+
+(defvar font-lock-delimiter-face 'font-lock-delimiter-face
+ "Face name to use for delimiters.")
+
+(defvar font-lock-escape-face 'font-lock-escape-face
+ "Face name to use for escape sequences in strings.")
+
+(defvar font-lock-number-face 'font-lock-number-face
+ "Face name to use for numbers.")
+
+(defvar font-lock-misc-punctuation-face 'font-lock-misc-punctuation-face
+ "Face name to use for miscellaneous punctuation.")
+
+(defvar font-lock-operator-face 'font-lock-operator-face
+ "Face name to use for operators.")
+
+(defvar font-lock-property-face 'font-lock-property-face
+ "Face name to use for properties.")
+
+(defvar font-lock-punctuation-face 'font-lock-punctuation-face
+ "Face name to use for punctuation.")
+
;; Fontification variables:
(defvar font-lock-keywords nil
@@ -2085,6 +2109,54 @@ font-lock-preprocessor-face
"Font Lock mode face used to highlight preprocessor directives."
:group 'font-lock-faces)
+(defface font-lock-bracket-face
+ '((t :inherit font-lock-punctuation-face))
+ "Font Lock mode face used to highlight brackets."
+ :group 'font-lock-faces
+ :version "29.1")
+
+(defface font-lock-delimiter-face
+ '((t :inherit font-lock-punctuation-face))
+ "Font Lock mode face used to highlight delimiters."
+ :group 'font-lock-faces
+ :version "29.1")
+
+(defface font-lock-escape-face
+ '((t :inherit font-lock-regexp-grouping-backslash))
+ "Font Lock mode face used to highlight escape sequences in strings."
+ :group 'font-lock-faces
+ :version "29.1")
+
+(defface font-lock-number-face
+ '((t nil))
+ "Font Lock mode face used to highlight numbers."
+ :group 'font-lock-faces
+ :version "29.1")
+
+(defface font-lock-misc-punctuation-face
+ '((t :inherit font-lock-punctuation-face))
+ "Font Lock mode face used to highlight miscellaneous punctuation."
+ :group 'font-lock-faces
+ :version "29.1")
+
+(defface font-lock-operator-face
+ '((t nil))
+ "Font Lock mode face used to highlight operators."
+ :group 'font-lock-faces
+ :version "29.1")
+
+(defface font-lock-property-face
+ '((t :inherit font-lock-variable-name-face))
+ "Font Lock mode face used to highlight properties."
+ :group 'font-lock-faces
+ :version "29.1")
+
+(defface font-lock-punctuation-face
+ '((t nil))
+ "Font Lock mode face used to highlight punctuation."
+ :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."
--
2.38.1
next prev parent reply other threads:[~2022-11-05 2:46 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-01 1:21 bug#58940: [PATCH] feature/tree-sitter: Add more font lock faces Randy Taylor
2022-11-01 2:14 ` Yuan Fu
2022-11-02 2:04 ` Randy Taylor
2022-11-02 12:27 ` Eli Zaretskii
2022-11-05 2:46 ` Randy Taylor [this message]
2022-11-05 9:24 ` Eli Zaretskii
2022-11-06 1:00 ` Randy Taylor
2022-11-06 6:14 ` Eli Zaretskii
2022-11-06 14:05 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-06 16:43 ` Randy Taylor
2022-11-06 19:24 ` Stefan Kangas
2022-11-07 1:33 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-07 3:31 ` Eli Zaretskii
2022-11-06 8:22 ` Eli Zaretskii
2022-11-06 17:02 ` Randy Taylor
2022-11-10 2:47 ` Randy Taylor
2022-11-10 3:59 ` Yuan Fu
2022-11-10 11:06 ` Eli Zaretskii
2022-11-01 22:54 ` Dmitry Gutov
2022-11-02 2:30 ` Randy Taylor
2022-11-02 13:41 ` Dmitry Gutov
2022-11-03 2:30 ` Randy Taylor
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='8ZKenedKBW2xqbSe_c0vWmeRbMQYCDlwFNvSMAYx9utQYeOKPHQQ-nKW9Y8nCcKRnFMmsnfonvA_0yixtSArBzVY_PkaNxxGWqhXoHjCZTo=@rjt.dev' \
--to=dev@rjt.dev \
--cc=58940@debbugs.gnu.org \
--cc=casouri@gmail.com \
--cc=eliz@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.