emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/expreg 9950c07ec9: * expreg.el (expreg--treesit): Add s


From: ELPA Syncer
Subject: [elpa] externals/expreg 9950c07ec9: * expreg.el (expreg--treesit): Add support for multi-language.
Date: Fri, 15 Sep 2023 18:57:47 -0400 (EDT)

branch: externals/expreg
commit 9950c07ec90293964baa33603f4a80e764b0a847
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    * expreg.el (expreg--treesit): Add support for multi-language.
---
 expreg.el | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/expreg.el b/expreg.el
index be49d8b53c..b03d69e11e 100644
--- a/expreg.el
+++ b/expreg.el
@@ -5,7 +5,7 @@
 ;; Author: Yuan Fu <casouri@gmail.com>
 ;; Maintainer: Yuan Fu <casouri@gmail.com>
 ;; URL: https://github.com/casouri/expreg
-;; Version: 1.2.1
+;; Version: 1.3.1
 ;; Keywords: text, editing
 ;; Package-Requires: ((emacs "29.1"))
 ;;
@@ -362,20 +362,24 @@ Only return something if ‘subword-mode’ is on, to keep 
consistency."
 (defun expreg--treesit ()
   "Return a list of regions according to tree-sitter."
   (when (treesit-parser-list)
-
-    (let ((node (treesit-node-at
-                 (point) (treesit-language-at (point))))
-          (root (treesit-buffer-root-node
-                 (treesit-language-at (point))))
+    (let ((parsers (append (treesit-parser-list)
+                           (and (fboundp #'treesit-local-parsers-at)
+                                (treesit-local-parsers-at (point)))))
           result)
-
-      (while node
-        (let ((beg (treesit-node-start node))
-              (end (treesit-node-end node)))
-          (when (not (treesit-node-eq node root))
-            (push `(treesit . ,(cons beg end)) result)))
-
-        (setq node (treesit-node-parent node)))
+      (dolist (parser parsers)
+        (let ((node (treesit-node-at (point) parser))
+              (root (treesit-parser-root-node parser))
+              (lang (treesit-parser-language parser)))
+
+          (while node
+            (let ((beg (treesit-node-start node))
+                  (end (treesit-node-end node)))
+              (when (not (treesit-node-eq node root))
+                (push (cons (intern (format "treesit--%s" lang))
+                            (cons beg end))
+                      result)))
+
+            (setq node (treesit-node-parent node)))))
       result)))
 
 (defun expreg--inside-list ()



reply via email to

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