emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 d2e82817a3f: Add two typescript-ts-mode faces (bug#62429)


From: Yuan Fu
Subject: emacs-29 d2e82817a3f: Add two typescript-ts-mode faces (bug#62429)
Date: Thu, 30 Mar 2023 04:10:27 -0400 (EDT)

branch: emacs-29
commit d2e82817a3f341e426c220e98048e1784d1e3076
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    Add two typescript-ts-mode faces (bug#62429)
    
    * lisp/progmodes/typescript-ts-mode.el:
    (typescript-ts-mode-jsx-tag-face)
    (typescript-ts-mode-jsx-attribute-face): New faces.
    (typescript-ts-mode--font-lock-settings): Use new faces.
    (tsx-ts-mode): Mention the new faces in the docstring.
---
 lisp/progmodes/typescript-ts-mode.el | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/lisp/progmodes/typescript-ts-mode.el 
b/lisp/progmodes/typescript-ts-mode.el
index a9ca85d5d35..23815c79906 100644
--- a/lisp/progmodes/typescript-ts-mode.el
+++ b/lisp/progmodes/typescript-ts-mode.el
@@ -41,6 +41,16 @@
   :safe 'integerp
   :group 'typescript)
 
+(defface typescript-ts-jsx-tag-face
+  '((t . (:inherit font-lock-function-call-face)))
+  "Face for HTML tags like <div> and <p> in JSX."
+  :group 'typescript)
+
+(defface typescript-ts-jsx-attribute-face
+  '((t . (:inherit font-lock-constant-face)))
+  "Face for HTML attributes like name and id in JSX."
+  :group 'typescript)
+
 (defvar typescript-ts-mode--syntax-table
   (let ((table (make-syntax-table)))
     ;; Taken from the cc-langs version
@@ -284,17 +294,17 @@ Argument LANGUAGE is either `typescript' or `tsx'."
    :feature 'jsx
    `((jsx_opening_element
       [(nested_identifier (identifier)) (identifier)]
-      @font-lock-function-call-face)
+      @typescript-ts-jsx-tag-face)
 
      (jsx_closing_element
       [(nested_identifier (identifier)) (identifier)]
-      @font-lock-function-call-face)
+      @typescript-ts-jsx-tag-face)
 
      (jsx_self_closing_element
       [(nested_identifier (identifier)) (identifier)]
-      @font-lock-function-call-face)
+      @typescript-ts-jsx-tag-face)
 
-     (jsx_attribute (property_identifier) @font-lock-constant-face))
+     (jsx_attribute (property_identifier) @typescript-ts-jsx-attribute-face))
 
    :language language
    :feature 'number
@@ -381,7 +391,12 @@ Argument LANGUAGE is either `typescript' or `tsx'."
 
 ;;;###autoload
 (define-derived-mode tsx-ts-mode typescript-ts-base-mode "TypeScript[TSX]"
-  "Major mode for editing TypeScript."
+  "Major mode for editing TSX and JSX documents.
+
+This major mode defines two additional JSX-specific faces:
+`typescript-ts-jsx-attribute-face' and
+`typescript-ts-jsx-attribute-face' that are used for HTML tags
+and attributes, respectively."
   :group 'typescript
   :syntax-table typescript-ts-mode--syntax-table
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]