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

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

[nongnu] elpa/treesit-fold 6a57bd945d 364/417: fix(cmake): Enhance body


From: ELPA Syncer
Subject: [nongnu] elpa/treesit-fold 6a57bd945d 364/417: fix(cmake): Enhance body folding
Date: Mon, 1 Jul 2024 10:03:05 -0400 (EDT)

branch: elpa/treesit-fold
commit 6a57bd945d7e7d8ac92950d6ded478847e460a85
Author: JenChieh <jcs090218@gmail.com>
Commit: JenChieh <jcs090218@gmail.com>

    fix(cmake): Enhance body folding
---
 ts-fold-parsers.el |  3 ++-
 ts-fold.el         | 11 +++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/ts-fold-parsers.el b/ts-fold-parsers.el
index 297cc3d233..8c9826f271 100644
--- a/ts-fold-parsers.el
+++ b/ts-fold-parsers.el
@@ -83,6 +83,7 @@
 (declare-function ts-fold-range-ocaml-value-definition "ts-fold.el")
 (declare-function ts-fold-range-org-body "ts-fold.el")
 (declare-function ts-fold-range-clojure-function "ts-fold.el")
+(declare-function ts-fold-range-cmake-body "ts-fold.el")
 (declare-function ts-fold-range-pascal-comment "ts-fold.el")
 (declare-function ts-fold-range-python-def "ts-fold.el")
 (declare-function ts-fold-range-python-expression-statement "ts-fold.el")
@@ -173,7 +174,7 @@
 
 (defun ts-fold-parsers-cmake ()
   "Rule set for CMake."
-  '((body . ts-fold-range-seq)
+  '((body . ts-fold-range-cmake-body)
     (line_comment
      . (lambda (node offset)
          (ts-fold-range-line-comment node offset "#")))))
diff --git a/ts-fold.el b/ts-fold.el
index 31c11493ca..e01075ac76 100644
--- a/ts-fold.el
+++ b/ts-fold.el
@@ -654,6 +654,17 @@ more information."
       (setq beg (ts-fold--last-eol beg)))
     (ts-fold--cons-add (cons beg end) offset)))
 
+(defun ts-fold-range-cmake-body (node offset)
+  "Return the fold range for `body' NODE in CMake.
+
+For arguments NODE and OFFSET, see function `ts-fold-range-seq' for
+more information."
+  (when-let* ((beg (tsc-node-start-position node))
+              (end (tsc-node-end-position node)))
+    (when ts-fold-on-next-line  ; display nicely
+      (setq end (ts-fold--last-eol end)))
+    (ts-fold--cons-add (cons beg end) offset)))
+
 (defun ts-fold-range-elisp-function (node offset)
   "Return the fold range for `macro_definition' and `function_definition' NODE
 in Elisp.



reply via email to

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