diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index c6cb9520e58..7f4f6f11387 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -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 diff --git a/lisp/progmodes/cmake-ts-mode.el b/lisp/progmodes/cmake-ts-mode.el index d83a956af21..9d35d8077bd 100644 --- a/lisp/progmodes/cmake-ts-mode.el +++ b/lisp/progmodes/cmake-ts-mode.el @@ -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 diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 44dfd74cafd..463872dcbc8 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -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 diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 52ed19cc682..414b6eb2baf 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -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 diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index fd196df7550..d9ca37145e1 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -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 diff --git a/lisp/progmodes/rust-ts-mode.el b/lisp/progmodes/rust-ts-mode.el index c3cf8d0cf44..b55af0b49e3 100644 --- a/lisp/progmodes/rust-ts-mode.el +++ b/lisp/progmodes/rust-ts-mode.el @@ -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 diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 54da1e0468e..9bc1f4dcfdc 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -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 diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 1c19a031878..5df34de0472 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -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 diff --git a/test/src/treesit-tests.el b/test/src/treesit-tests.el index fef603840f9..69db37fc0b4 100644 --- a/test/src/treesit-tests.el +++ b/test/src/treesit-tests.el @@ -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