1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-26 07:33:47 +00:00

Fix bol/bos anchors in tree-sitter :match regexps

Further regexp fixes to follow separately (bug#64019#29).

* lisp/progmodes/c-ts-mode.el (c-ts-mode--font-lock-settings):
* lisp/progmodes/cmake-ts-mode.el
(cmake-ts-mode--font-lock-settings):
* lisp/progmodes/java-ts-mode.el (java-ts-mode--font-lock-settings):
* lisp/progmodes/js.el (js--treesit-font-lock-settings):
* lisp/progmodes/python.el (python--treesit-settings):
* lisp/progmodes/rust-ts-mode.el (rust-ts-mode--font-lock-settings):
* lisp/progmodes/sh-script.el (sh-mode--treesit-settings):
* lisp/progmodes/typescript-ts-mode.el
(typescript-ts-mode--font-lock-settings):
* test/src/treesit-tests.el (treesit-query-api): Anchor :match
regexps at beginning/end of string, not line.
This commit is contained in:
Basil L. Contovounesios 2023-06-13 13:45:08 +01:00
parent 8225ade615
commit 8dc08333ee
9 changed files with 19 additions and 18 deletions

View File

@ -701,7 +701,7 @@ MODE is either `c' or `cpp'."
`(((call_expression
(call_expression function: (identifier) @fn)
@c-ts-mode--fontify-DEFUN)
(:match "^DEFUN$" @fn))
(:match "\\`DEFUN\\'" @fn))
((function_definition type: (_) @for-each-tail)
@c-ts-mode--fontify-for-each-tail

View File

@ -134,7 +134,8 @@
:language 'cmake
:feature 'number
'(((unquoted_argument) @font-lock-number-face
(:match "^[[:digit:]]*\\.?[[:digit:]]*\\.?[[:digit:]]+$" @font-lock-number-face)))
(:match "\\`[[:digit:]]*\\.?[[:digit:]]*\\.?[[:digit:]]+\\'"
@font-lock-number-face)))
:language 'cmake
:feature 'string

View File

@ -168,7 +168,7 @@ the available version of Tree-sitter for java."
:override t
:feature 'constant
`(((identifier) @font-lock-constant-face
(:match "^[A-Z_][A-Z_\\d]*$" @font-lock-constant-face))
(:match "\\`[A-Z_][A-Z_\\d]*\\'" @font-lock-constant-face))
[(true) (false)] @font-lock-constant-face)
:language 'java
:override t
@ -237,7 +237,7 @@ the available version of Tree-sitter for java."
(scoped_identifier (identifier) @font-lock-constant-face)
((scoped_identifier name: (identifier) @font-lock-type-face)
(:match "^[A-Z]" @font-lock-type-face))
(:match "\\`[A-Z]" @font-lock-type-face))
(type_identifier) @font-lock-type-face

View File

@ -3493,7 +3493,7 @@ This function is intended for use in `after-change-functions'."
:language 'javascript
:feature 'constant
'(((identifier) @font-lock-constant-face
(:match "^[A-Z_][A-Z_\\d]*$" @font-lock-constant-face))
(:match "\\`[A-Z_][A-Z_\\d]*\\'" @font-lock-constant-face))
[(true) (false) (null)] @font-lock-constant-face)
@ -3612,7 +3612,7 @@ This function is intended for use in `after-change-functions'."
:feature 'number
'((number) @font-lock-number-face
((identifier) @font-lock-number-face
(:match "^\\(:?NaN\\|Infinity\\)$" @font-lock-number-face)))
(:match "\\`\\(:?NaN\\|Infinity\\)\\'" @font-lock-number-face)))
:language 'javascript
:feature 'operator

View File

@ -1106,7 +1106,7 @@ fontified."
:language 'python
`([,@python--treesit-keywords] @font-lock-keyword-face
((identifier) @font-lock-keyword-face
(:match "^self$" @font-lock-keyword-face)))
(:match "\\`self\\'" @font-lock-keyword-face)))
:feature 'definition
:language 'python

View File

@ -143,7 +143,7 @@
eol))
@font-lock-builtin-face)))
((identifier) @font-lock-type-face
(:match "^\\(:?Err\\|Ok\\|None\\|Some\\)$" @font-lock-type-face)))
(:match "\\`\\(:?Err\\|Ok\\|None\\|Some\\)\\'" @font-lock-type-face)))
:language 'rust
:feature 'comment
@ -212,11 +212,11 @@
(scoped_use_list path: (scoped_identifier
name: (identifier) @font-lock-constant-face))
((use_as_clause alias: (identifier) @font-lock-type-face)
(:match "^[A-Z]" @font-lock-type-face))
(:match "\\`[A-Z]" @font-lock-type-face))
((use_as_clause path: (identifier) @font-lock-type-face)
(:match "^[A-Z]" @font-lock-type-face))
(:match "\\`[A-Z]" @font-lock-type-face))
((use_list (identifier) @font-lock-type-face)
(:match "^[A-Z]" @font-lock-type-face))
(:match "\\`[A-Z]" @font-lock-type-face))
(use_wildcard [(identifier) @rust-ts-mode--fontify-scope
(scoped_identifier
name: (identifier) @rust-ts-mode--fontify-scope)])
@ -233,7 +233,7 @@
((scoped_identifier name: (identifier) @rust-ts-mode--fontify-tail))
((scoped_identifier path: (identifier) @font-lock-type-face)
(:match
"^\\(u8\\|u16\\|u32\\|u64\\|u128\\|usize\\|i8\\|i16\\|i32\\|i64\\|i128\\|isize\\|char\\|str\\)$"
"\\`\\(u8\\|u16\\|u32\\|u64\\|u128\\|usize\\|i8\\|i16\\|i32\\|i64\\|i128\\|isize\\|char\\|str\\)\\'"
@font-lock-type-face))
((scoped_identifier path: (identifier) @rust-ts-mode--fontify-scope))
((scoped_type_identifier path: (identifier) @rust-ts-mode--fontify-scope))
@ -249,7 +249,7 @@
:feature 'constant
`((boolean_literal) @font-lock-constant-face
((identifier) @font-lock-constant-face
(:match "^[A-Z][A-Z\\d_]*$" @font-lock-constant-face)))
(:match "\\`[A-Z][A-Z\\d_]*\\'" @font-lock-constant-face)))
:language 'rust
:feature 'variable

View File

@ -3363,7 +3363,7 @@ See `sh-mode--treesit-other-keywords' and
:feature 'number
:language 'bash
`(((word) @font-lock-number-face
(:match "^[0-9]+$" @font-lock-number-face)))
(:match "\\`[0-9]+\\'" @font-lock-number-face)))
:feature 'bracket
:language 'bash

View File

@ -153,7 +153,7 @@ Argument LANGUAGE is either `typescript' or `tsx'."
:language language
:feature 'constant
`(((identifier) @font-lock-constant-face
(:match "^[A-Z_][A-Z_\\d]*$" @font-lock-constant-face))
(:match "\\`[A-Z_][A-Z_\\d]*\\'" @font-lock-constant-face))
[(true) (false) (null)] @font-lock-constant-face)
:language language
@ -311,7 +311,7 @@ Argument LANGUAGE is either `typescript' or `tsx'."
:feature 'number
`((number) @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
:feature 'operator

View File

@ -368,14 +368,14 @@ BODY is the test body."
;; String query.
'("(string) @string
(pair key: (_) @keyword)
((_) @bob (#match \"^B.b$\" @bob))
((_) @bob (#match \"\\\\`B.b\\\\'\" @bob))
(number) @number
((number) @n3 (#equal \"3\" @n3))
((number) @n3p (#pred treesit--ert-pred-last-sibling @n3p))"
;; Sexp query.
((string) @string
(pair key: (_) @keyword)
((_) @bob (:match "^B.b$" @bob))
((_) @bob (:match "\\`B.b\\'" @bob))
(number) @number
((number) @n3 (:equal "3" @n3))
((number) @n3p (:pred treesit--ert-pred-last-sibling