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

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

[nongnu] elpa/treesit-fold 75e72c658a 332/417: feat: Add Org support


From: ELPA Syncer
Subject: [nongnu] elpa/treesit-fold 75e72c658a 332/417: feat: Add Org support
Date: Mon, 1 Jul 2024 10:03:00 -0400 (EDT)

branch: elpa/treesit-fold
commit 75e72c658ad8d8aac3af554a6b51b3c5c22dd0aa
Author: JenChieh <jcs090218@gmail.com>
Commit: Jen-Chieh Shen <jcs090218@gmail.com>

    feat: Add Org support
---
 CHANGELOG.md       |  1 +
 README.md          |  2 +-
 ts-fold-parsers.el | 12 +++++++++++-
 ts-fold.el         | 11 +++++++++++
 4 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index b378811a23..0b91e7e5d4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -30,6 +30,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for 
recommendations on how
 * perf: Render indicators in display range (#97)
 * fix: Don't render indicators on non-foldable node 
(342eb5ee1f242ac03bc7e7bbe8d67be8711423ae)
 * Add `Groovy` and `Jenkinsfile` support (#98)
+* Add `Org` support (#100)
 
 ## 0.2.0
 > Released Sep 01, 2023
diff --git a/README.md b/README.md
index 9fce1ab4ef..df42b881dd 100644
--- a/README.md
+++ b/README.md
@@ -125,7 +125,7 @@ These languages are fairly complete:
 - LaTex / Lisp / Lua
 - Make / Markdown
 - Nix / Noir
-- OCaml
+- OCaml / Org
 - Perl / PHP / Python
 - R / Ruby / Rust / reStructuredText
 - Scala / Scheme / SQL / Swift
diff --git a/ts-fold-parsers.el b/ts-fold-parsers.el
index 898d0b8d4e..51fbeaf676 100644
--- a/ts-fold-parsers.el
+++ b/ts-fold-parsers.el
@@ -66,7 +66,11 @@
 (declare-function ts-fold-range-lua-do-loop "ts-fold.el")
 (declare-function ts-fold-range-lua-repeat "ts-fold.el")
 (declare-function ts-fold-range-make-recipe "ts-fold.el")
-(declare-function ts-fold-range-ocaml "ts-fold.el")
+(declare-function ts-fold-range-ocaml-comment "ts-fold.el")
+(declare-function ts-fold-range-ocaml-module-definition "ts-fold.el")
+(declare-function ts-fold-range-ocaml-type-definition "ts-fold.el")
+(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-pascal-comment "ts-fold.el")
 (declare-function ts-fold-range-python-def "ts-fold.el")
@@ -396,6 +400,12 @@
     (type_definition     . ts-fold-range-ocaml-type-definition)
     (value_definition    . ts-fold-range-ocaml-value-definition)))
 
+(defun ts-fold-parsers-org ()
+  "Rule set for Org."
+  '((body    . ts-fold-range-org-body)
+    (block   . ts-fold-range-seq)
+    (comment . ts-fold-range-seq)))
+
 (defun ts-fold-parsers-pascal ()
   "Rule set for Pascal."
   '((comment . ts-fold-range-pascal-comment)))
diff --git a/ts-fold.el b/ts-fold.el
index 411a86aef7..a3aea6c091 100644
--- a/ts-fold.el
+++ b/ts-fold.el
@@ -111,6 +111,7 @@
     (noir-mode              . ,(ts-fold-parsers-noir))
     (nix-mode               . ,(ts-fold-parsers-nix))
     (ocaml-mode             . ,(ts-fold-parsers-ocaml))
+    (org-mode               . ,(ts-fold-parsers-org))
     (pascal-mode            . ,(ts-fold-parsers-pascal))
     (perl-mode              . ,(ts-fold-parsers-perl))
     (php-mode               . ,(ts-fold-parsers-php))
@@ -961,6 +962,16 @@ more information."
 
 ;;- OCaml
 
+(defun ts-fold-range-org-body (node offset)
+  "Define fold range for `body' in Org.
+
+For arguments NODE and OFFSET, see function `ts-fold-range-seq' for
+more information."
+  (when-let*
+      ((parent (tsc-get-parent node))
+       (parent (tsc-get-parent parent)))
+    (ts-fold--cons-add (cons -1 0) (ts-fold-range-seq node offset))))
+
 (defun ts-fold-range-pascal-comment (node offset)
   "Define fold range for `comment' in Pascal.
 



reply via email to

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