Merge branch 'emacs-29' of git.sv.gnu.org:/srv/git/emacs into emacs-29

This commit is contained in:
Michael Albinus 2024-02-12 13:21:53 +01:00
commit df243f785d
3 changed files with 155 additions and 139 deletions

View file

@ -203,6 +203,8 @@ Return them as multiple value."
t) t)
((and (not (symbolp x)) (symbolp y)) ((and (not (symbolp x)) (symbolp y))
nil) nil)
((or (consp x) (consp y)
nil))
(t (t
(< (sxhash-equal x) (< (sxhash-equal x)
(sxhash-equal y))))))) (sxhash-equal y)))))))

View file

@ -318,8 +318,8 @@ Using the value `insert' is not recommended in editable
buffers because it modifies them. buffers because it modifies them.
When the value is `in-margins', then clickable buttons are When the value is `in-margins', then clickable buttons are
displayed in the margins before the headings. displayed in the margins before the headings.
When the value is `t', clickable buttons are displayed When the value is t, clickable buttons are displayed
in the buffer before the headings. The values `t' and in the buffer before the headings. The values t and
`in-margins' can be used in editing buffers because they `in-margins' can be used in editing buffers because they
don't modify the buffer." don't modify the buffer."
;; The value `insert' is not intended to be customizable. ;; The value `insert' is not intended to be customizable.

View file

@ -199,183 +199,197 @@ Argument LANGUAGE is either `typescript' or `tsx'."
[(nested_identifier (identifier)) (identifier)] [(nested_identifier (identifier)) (identifier)]
@typescript-ts-jsx-tag-face))))) @typescript-ts-jsx-tag-face)))))
(defun tsx-ts-mode--font-lock-compatibility-function-expression (language)
"Handle tree-sitter grammar breaking change for `function' expression.
LANGUAGE can be `typescript' or `tsx'. Starting from version 0.20.4 of the
typescript/tsx grammar, `function' becomes `function_expression'."
(condition-case nil
(progn (treesit-query-capture language '((function_expression) @cap))
;; New version of the grammar
'function_expression)
(treesit-query-error
;; Old version of the grammar
'function)))
(defun typescript-ts-mode--font-lock-settings (language) (defun typescript-ts-mode--font-lock-settings (language)
"Tree-sitter font-lock settings. "Tree-sitter font-lock settings.
Argument LANGUAGE is either `typescript' or `tsx'." Argument LANGUAGE is either `typescript' or `tsx'."
(treesit-font-lock-rules (let ((func-exp (tsx-ts-mode--font-lock-compatibility-function-expression language)))
:language language (treesit-font-lock-rules
:feature 'comment :language language
`([(comment) (hash_bang_line)] @font-lock-comment-face) :feature 'comment
`([(comment) (hash_bang_line)] @font-lock-comment-face)
:language language :language language
:feature 'constant :feature 'constant
`(((identifier) @font-lock-constant-face `(((identifier) @font-lock-constant-face
(:match "\\`[A-Z_][0-9A-Z_]*\\'" @font-lock-constant-face)) (:match "\\`[A-Z_][0-9A-Z_]*\\'" @font-lock-constant-face))
[(true) (false) (null)] @font-lock-constant-face) [(true) (false) (null)] @font-lock-constant-face)
:language language :language language
:feature 'keyword :feature 'keyword
`([,@typescript-ts-mode--keywords] @font-lock-keyword-face `([,@typescript-ts-mode--keywords] @font-lock-keyword-face
[(this) (super)] @font-lock-keyword-face) [(this) (super)] @font-lock-keyword-face)
:language language :language language
:feature 'string :feature 'string
`((regex pattern: (regex_pattern)) @font-lock-regexp-face `((regex pattern: (regex_pattern)) @font-lock-regexp-face
(string) @font-lock-string-face (string) @font-lock-string-face
(template_string) @js--fontify-template-string (template_string) @js--fontify-template-string
(template_substitution ["${" "}"] @font-lock-misc-punctuation-face)) (template_substitution ["${" "}"] @font-lock-misc-punctuation-face))
:language language :language language
:override t ;; for functions assigned to variables :override t ;; for functions assigned to variables
:feature 'declaration :feature 'declaration
`((function `((,func-exp
name: (identifier) @font-lock-function-name-face) name: (identifier) @font-lock-function-name-face)
(function_declaration (function_declaration
name: (identifier) @font-lock-function-name-face) name: (identifier) @font-lock-function-name-face)
(function_signature (function_signature
name: (identifier) @font-lock-function-name-face) name: (identifier) @font-lock-function-name-face)
(method_definition (method_definition
name: (property_identifier) @font-lock-function-name-face) name: (property_identifier) @font-lock-function-name-face)
(method_signature (method_signature
name: (property_identifier) @font-lock-function-name-face) name: (property_identifier) @font-lock-function-name-face)
(required_parameter (identifier) @font-lock-variable-name-face) (required_parameter (identifier) @font-lock-variable-name-face)
(optional_parameter (identifier) @font-lock-variable-name-face) (optional_parameter (identifier) @font-lock-variable-name-face)
(variable_declarator (variable_declarator
name: (identifier) @font-lock-function-name-face name: (identifier) @font-lock-function-name-face
value: [(function) (arrow_function)]) value: [(,func-exp) (arrow_function)])
(variable_declarator (variable_declarator
name: (identifier) @font-lock-variable-name-face) name: (identifier) @font-lock-variable-name-face)
(enum_declaration (identifier) @font-lock-type-face) (enum_declaration (identifier) @font-lock-type-face)
(extends_clause value: (identifier) @font-lock-type-face) (extends_clause value: (identifier) @font-lock-type-face)
;; extends React.Component<T> ;; extends React.Component<T>
(extends_clause value: (member_expression (extends_clause value: (member_expression
object: (identifier) @font-lock-type-face object: (identifier) @font-lock-type-face
property: (property_identifier) @font-lock-type-face)) property: (property_identifier) @font-lock-type-face))
(arrow_function (arrow_function
parameter: (identifier) @font-lock-variable-name-face) parameter: (identifier) @font-lock-variable-name-face)
(variable_declarator (variable_declarator
name: (array_pattern name: (array_pattern
(identifier) (identifier)
(identifier) @font-lock-function-name-face) (identifier) @font-lock-function-name-face)
value: (array (number) (function))) value: (array (number) (,func-exp)))
(catch_clause (catch_clause
parameter: (identifier) @font-lock-variable-name-face) parameter: (identifier) @font-lock-variable-name-face)
;; full module imports ;; full module imports
(import_clause (identifier) @font-lock-variable-name-face) (import_clause (identifier) @font-lock-variable-name-face)
;; named imports with aliasing ;; named imports with aliasing
(import_clause (named_imports (import_specifier (import_clause (named_imports (import_specifier
alias: (identifier) @font-lock-variable-name-face))) alias: (identifier) @font-lock-variable-name-face)))
;; named imports without aliasing ;; named imports without aliasing
(import_clause (named_imports (import_specifier (import_clause (named_imports (import_specifier
!alias !alias
name: (identifier) @font-lock-variable-name-face))) name: (identifier) @font-lock-variable-name-face)))
;; full namespace import (* as alias) ;; full namespace import (* as alias)
(import_clause (namespace_import (identifier) @font-lock-variable-name-face))) (import_clause (namespace_import (identifier) @font-lock-variable-name-face)))
:language language :language language
:feature 'identifier :feature 'identifier
`((nested_type_identifier `((nested_type_identifier
module: (identifier) @font-lock-type-face) module: (identifier) @font-lock-type-face)
(type_identifier) @font-lock-type-face (type_identifier) @font-lock-type-face
(predefined_type) @font-lock-type-face (predefined_type) @font-lock-type-face
(new_expression (new_expression
constructor: (identifier) @font-lock-type-face) constructor: (identifier) @font-lock-type-face)
(enum_body (property_identifier) @font-lock-type-face) (enum_body (property_identifier) @font-lock-type-face)
(enum_assignment name: (property_identifier) @font-lock-type-face) (enum_assignment name: (property_identifier) @font-lock-type-face)
(variable_declarator (variable_declarator
name: (identifier) @font-lock-variable-name-face) name: (identifier) @font-lock-variable-name-face)
(for_in_statement (for_in_statement
left: (identifier) @font-lock-variable-name-face) left: (identifier) @font-lock-variable-name-face)
(arrow_function (arrow_function
parameters: parameters:
[(_ (identifier) @font-lock-variable-name-face) [(_ (identifier) @font-lock-variable-name-face)
(_ (_ (identifier) @font-lock-variable-name-face)) (_ (_ (identifier) @font-lock-variable-name-face))
(_ (_ (_ (identifier) @font-lock-variable-name-face)))])) (_ (_ (_ (identifier) @font-lock-variable-name-face)))]))
:language language :language language
:feature 'property :feature 'property
`((property_signature `((property_signature
name: (property_identifier) @font-lock-property-name-face) name: (property_identifier) @font-lock-property-name-face)
(public_field_definition (public_field_definition
name: (property_identifier) @font-lock-property-name-face) name: (property_identifier) @font-lock-property-name-face)
(pair key: (property_identifier) @font-lock-property-use-face) (pair key: (property_identifier) @font-lock-property-use-face)
((shorthand_property_identifier) @font-lock-property-use-face)) ((shorthand_property_identifier) @font-lock-property-use-face))
:language language :language language
:feature 'expression :feature 'expression
'((assignment_expression `((assignment_expression
left: [(identifier) @font-lock-function-name-face left: [(identifier) @font-lock-function-name-face
(member_expression (member_expression
property: (property_identifier) @font-lock-function-name-face)] property: (property_identifier) @font-lock-function-name-face)]
right: [(function) (arrow_function)])) right: [(,func-exp) (arrow_function)]))
:language language :language language
:feature 'function :feature 'function
'((call_expression '((call_expression
function: function:
[(identifier) @font-lock-function-call-face [(identifier) @font-lock-function-call-face
(member_expression (member_expression
property: (property_identifier) @font-lock-function-call-face)])) property: (property_identifier) @font-lock-function-call-face)]))
:language language :language language
:feature 'pattern :feature 'pattern
`((pair_pattern `((pair_pattern
key: (property_identifier) @font-lock-property-use-face key: (property_identifier) @font-lock-property-use-face
value: [(identifier) @font-lock-variable-name-face value: [(identifier) @font-lock-variable-name-face
(assignment_pattern left: (identifier) @font-lock-variable-name-face)]) (assignment_pattern left: (identifier) @font-lock-variable-name-face)])
(array_pattern (identifier) @font-lock-variable-name-face) (array_pattern (identifier) @font-lock-variable-name-face)
((shorthand_property_identifier_pattern) @font-lock-variable-name-face)) ((shorthand_property_identifier_pattern) @font-lock-variable-name-face))
:language language :language language
:feature 'jsx :feature 'jsx
(append (tsx-ts-mode--font-lock-compatibility-bb1f97b language) (append (tsx-ts-mode--font-lock-compatibility-bb1f97b language)
`((jsx_attribute (property_identifier) @typescript-ts-jsx-attribute-face))) `((jsx_attribute (property_identifier) @typescript-ts-jsx-attribute-face)))
:language language :language language
:feature 'number :feature 'number
`((number) @font-lock-number-face `((number) @font-lock-number-face
((identifier) @font-lock-number-face ((identifier) @font-lock-number-face
(:match "\\`\\(?:NaN\\|Infinity\\)\\'" @font-lock-number-face))) (:match "\\`\\(?:NaN\\|Infinity\\)\\'" @font-lock-number-face)))
:language language :language language
:feature 'operator :feature 'operator
`([,@typescript-ts-mode--operators] @font-lock-operator-face `([,@typescript-ts-mode--operators] @font-lock-operator-face
(ternary_expression ["?" ":"] @font-lock-operator-face)) (ternary_expression ["?" ":"] @font-lock-operator-face))
:language language :language language
:feature 'bracket :feature 'bracket
'((["(" ")" "[" "]" "{" "}"]) @font-lock-bracket-face) '((["(" ")" "[" "]" "{" "}"]) @font-lock-bracket-face)
:language language :language language
:feature 'delimiter :feature 'delimiter
'((["," "." ";" ":"]) @font-lock-delimiter-face) '((["," "." ";" ":"]) @font-lock-delimiter-face)
:language language :language language
:feature 'escape-sequence :feature 'escape-sequence
:override t :override t
'((escape_sequence) @font-lock-escape-face))) '((escape_sequence) @font-lock-escape-face))))
;;;###autoload ;;;###autoload
(define-derived-mode typescript-ts-base-mode prog-mode "TypeScript" (define-derived-mode typescript-ts-base-mode prog-mode "TypeScript"