aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2025-02-17 19:40:20 +0200
committerJuri Linkov2025-02-17 19:40:20 +0200
commit1a8493f0a5fcd45c7e992dbf42cfbb0346edcaff (patch)
tree9ece0dd9b6278c92b0a432fe1e4976903afb4dd6
parentc380a72679a0626cda23072e082955967c1e99f5 (diff)
downloademacs-1a8493f0a5fcd45c7e992dbf42cfbb0346edcaff.tar.gz
emacs-1a8493f0a5fcd45c7e992dbf42cfbb0346edcaff.zip
; Small fixes for the recently added 'mhtml-ts-mode'
* lisp/textmodes/mhtml-ts-mode.el (mhtml-ts-mode): Add autoload cookie. * lisp/treesit.el (treesit-modify-indent-rules): Use 'rules' instead of 'js--treesit-indent-rules'.
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/textmodes/mhtml-ts-mode.el5
-rw-r--r--lisp/treesit.el4
3 files changed, 5 insertions, 8 deletions
diff --git a/etc/NEWS b/etc/NEWS
index dcb9c1c51e4..190da3e3797 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1392,14 +1392,11 @@ language symbol. For example, 'cpp' is translated to "C++". A new
1392variable 'treesit-language-display-name-alist' holds the translations of 1392variable 'treesit-language-display-name-alist' holds the translations of
1393language symbols where that translation is not trivial. 1393language symbols where that translation is not trivial.
1394 1394
1395+++
1396++++
1397*** New function 'treesit-merge-font-lock-feature-list'. 1395*** New function 'treesit-merge-font-lock-feature-list'.
1398This function merges two tree-sitter font-lock feature lists. Returns a 1396This function merges two tree-sitter font-lock feature lists. Returns a
1399new font-lock feature list with no duplicates in the same level. It can 1397new font-lock feature list with no duplicates in the same level. It can
1400be used to merge font-lock feature lists in a multi-language major mode. 1398be used to merge font-lock feature lists in a multi-language major mode.
1401 1399
1402+++
1403*** New function 'treesit-replace-font-lock-feature-settings'. 1400*** New function 'treesit-replace-font-lock-feature-settings'.
1404Given two tree-sitter font-lock settings, it replaces the feature in the 1401Given two tree-sitter font-lock settings, it replaces the feature in the
1405second font-lock settings with the same feature in the first font-lock 1402second font-lock settings with the same feature in the first font-lock
@@ -1407,7 +1404,6 @@ settings. In a multi-language major mode it is sometimes necessary to
1407replace features from one of the major modes, with others that are 1404replace features from one of the major modes, with others that are
1408better suited to the new multilingual context. 1405better suited to the new multilingual context.
1409 1406
1410+++
1411*** New function 'treesit-modify-indent-rules'. 1407*** New function 'treesit-modify-indent-rules'.
1412Given two tree-sitter indent rules, it replaces, adds, or prepends the 1408Given two tree-sitter indent rules, it replaces, adds, or prepends the
1413new rules to the old ones, then returns the new tree-sitter indent 1409new rules to the old ones, then returns the new tree-sitter indent
diff --git a/lisp/textmodes/mhtml-ts-mode.el b/lisp/textmodes/mhtml-ts-mode.el
index 9be1a14c257..bdb016d67dc 100644
--- a/lisp/textmodes/mhtml-ts-mode.el
+++ b/lisp/textmodes/mhtml-ts-mode.el
@@ -1,6 +1,6 @@
1;;; mhtml-ts-mode.el --- Major mode for HTML using tree-sitter -*- lexical-binding: t; -*- 1;;; mhtml-ts-mode.el --- Major mode for HTML using tree-sitter -*- lexical-binding: t; -*-
2 2
3;; Copyright (C) 2024 Free Software Foundation, Inc. 3;; Copyright (C) 2024-2025 Free Software Foundation, Inc.
4 4
5;; Author: Vincenzo Pupillo <v.pupillo@gmail.com> 5;; Author: Vincenzo Pupillo <v.pupillo@gmail.com>
6;; Maintainer: Vincenzo Pupillo <v.pupillo@gmail.com> 6;; Maintainer: Vincenzo Pupillo <v.pupillo@gmail.com>
@@ -248,7 +248,7 @@ For NODE, OVERRIDE, START, and END, see `treesit-font-lock-rules'."
248 'font-lock-variable-name-face 248 'font-lock-variable-name-face
249 override start end))) 249 override start end)))
250 250
251;; Embedded languages ​​should be indented according to the language 251;; Embedded languages should be indented according to the language
252;; that embeds them. 252;; that embeds them.
253;; This function signature complies with `treesit-simple-indent-rules' 253;; This function signature complies with `treesit-simple-indent-rules'
254;; ANCHOR. 254;; ANCHOR.
@@ -440,6 +440,7 @@ Calls REPORT-FN directly. Requires tidy."
440 (process-send-region mhtml-ts-mode--flymake-process (point-min) (point-max)) 440 (process-send-region mhtml-ts-mode--flymake-process (point-min) (point-max))
441 (process-send-eof mhtml-ts-mode--flymake-process))))) 441 (process-send-eof mhtml-ts-mode--flymake-process)))))
442 442
443;;;###autoload
443(define-derived-mode mhtml-ts-mode html-ts-mode 444(define-derived-mode mhtml-ts-mode html-ts-mode
444 '("HTML+" (:eval (let ((lang (mhtml-ts-mode--language-at-point (point)))) 445 '("HTML+" (:eval (let ((lang (mhtml-ts-mode--language-at-point (point))))
445 (cond ((eq lang 'html) "") 446 (cond ((eq lang 'html) "")
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 30fe3798bd9..cd95524fdf4 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -1322,7 +1322,7 @@ and leave settings for other languages unchanged."
1322Returns a new font lock feature list with no duplicates in the same level. 1322Returns a new font lock feature list with no duplicates in the same level.
1323It can be used to merge font lock feature lists in a multi-language major mode. 1323It can be used to merge font lock feature lists in a multi-language major mode.
1324FEATURES-LIST-1 and FEATURES-LIST-2 are list of lists of feature symbols." 1324FEATURES-LIST-1 and FEATURES-LIST-2 are list of lists of feature symbols."
1325 (let ((result nil) 1325 (let ((result nil)
1326 (features-1 (car features-list-1)) 1326 (features-1 (car features-list-1))
1327 (features-2 (car features-list-2))) 1327 (features-2 (car features-list-2)))
1328 (while (or features-1 features-2) 1328 (while (or features-1 features-2)
@@ -2551,7 +2551,7 @@ NEW-RULES replace rule in RULES which the same anchor."
2551 (error "No rules for language %s in RULES" lang)) 2551 (error "No rules for language %s in RULES" lang))
2552 ((not (alist-get lang new-rules)) 2552 ((not (alist-get lang new-rules))
2553 (error "No rules for language %s in NEW-RULES" lang)) 2553 (error "No rules for language %s in NEW-RULES" lang))
2554 (t (let* ((copy-of-rules (copy-tree js--treesit-indent-rules)) 2554 (t (let* ((copy-of-rules (copy-tree rules))
2555 (lang-rules (alist-get lang copy-of-rules)) 2555 (lang-rules (alist-get lang copy-of-rules))
2556 (lang-new-rules (alist-get lang new-rules))) 2556 (lang-new-rules (alist-get lang new-rules)))
2557 (cond 2557 (cond