[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/treesit-fold be2b3dd211 275/417: feat: Add Elisp support (
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/treesit-fold be2b3dd211 275/417: feat: Add Elisp support (#63) |
Date: |
Mon, 1 Jul 2024 10:02:34 -0400 (EDT) |
branch: elpa/treesit-fold
commit be2b3dd211b1bb4c55a1ae823646e0b1436f721f
Author: Jen-Chieh Shen <jcs090218@gmail.com>
Commit: GitHub <noreply@github.com>
feat: Add Elisp support (#63)
* feat: Add Elisp support
* changelog
* Add elisp
---
CHANGELOG.md | 1 +
README.md | 3 +--
ts-fold-parsers.el | 9 +++++++++
ts-fold-summary.el | 5 +++++
ts-fold.el | 12 ++++++++++++
5 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d11d505db7..291a43c9d6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,6 +21,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for
recommendations on how
* Add support for Lua (#52)
* Add support for Python docstring (#58)
* Add Dart support (#62)
+* Add Elisp support (#63)
## 0.1.0
> Released Oct 18, 2021
diff --git a/README.md b/README.md
index aa833889c0..698a8e6a3c 100644
--- a/README.md
+++ b/README.md
@@ -115,7 +115,7 @@ These languages are fairly complete:
- Bash
- C / C++ / C# / CSS
- Dart
-- Elixir
+- Elisp / Elixir
- Go
- HTML
- Java / JavaScript / JSX / JSON / Julia
@@ -131,7 +131,6 @@ These languages are in development:
- Agda
- Elm
-- Emacs Lisp
- OCaml
- XML (upstream)
diff --git a/ts-fold-parsers.el b/ts-fold-parsers.el
index b9f5e9654c..f98c77a27b 100644
--- a/ts-fold-parsers.el
+++ b/ts-fold-parsers.el
@@ -59,6 +59,7 @@
(declare-function ts-fold-range-ruby-class-def "ts-fold.el")
(declare-function ts-fold-range-ruby-if "ts-fold.el")
(declare-function ts-fold-range-rust-macro "ts-fold.el")
+(declare-function ts-fold-range-elisp-function "ts-fold.el")
(declare-function ts-fold-range-elixir "ts-fold.el")
;;
@@ -127,6 +128,14 @@
(documentation_comment . ts-fold-range-c-like-comment)
(list_literal . ts-fold-range-seq))) ; array
+(defun ts-fold-parsers-elisp ()
+ "Rule set for Elisp."
+ '((macro_definition . ts-fold-range-elisp-function)
+ (function_definition . ts-fold-range-elisp-function)
+ (comment
+ . (lambda (node offset)
+ (ts-fold-range-line-comment node offset ";;")))))
+
(defun ts-fold-parsers-elixir ()
"Rules set for Elixir."
'((list . ts-fold-range-seq)
diff --git a/ts-fold-summary.el b/ts-fold-summary.el
index 75e6217e1d..4bf0532380 100644
--- a/ts-fold-summary.el
+++ b/ts-fold-summary.el
@@ -112,6 +112,10 @@ type of content by checking the word boundary's existence."
(ts-fold-summary-csharp-vsdoc doc-str))
(t (ts-fold-summary-javadoc doc-str))))
+(defun ts-fold-summary-elisp (doc-str)
+ "Extract summary from DOC-STR in Elisp."
+ (ts-fold-summary--generic doc-str ";;"))
+
(defun ts-fold-summary-javadoc (doc-str)
"Extract summary from DOC-STR in Javadoc."
(ts-fold-summary--generic doc-str "*"))
@@ -206,6 +210,7 @@ type of content by checking the word boundary's existence."
(csharp-mode . ts-fold-summary-csharp)
(css-mode . ts-fold-summary-javadoc)
(dart-mode . ts-fold-summary-javadoc)
+ (emacs-lisp-mode . ts-fold-summary-elisp)
(go-mode . ts-fold-summary-go)
(html-mode . ts-fold-summary-xml)
(java-mode . ts-fold-summary-javadoc)
diff --git a/ts-fold.el b/ts-fold.el
index fd32145ca1..77b8d48aa0 100644
--- a/ts-fold.el
+++ b/ts-fold.el
@@ -66,6 +66,7 @@
(csharp-mode . ,(ts-fold-parsers-csharp))
(css-mode . ,(ts-fold-parsers-css))
(dart-mode . ,(ts-fold-parsers-dart))
+ (emacs-lisp-mode . ,(ts-fold-parsers-elisp))
(elixir-mode . ,(ts-fold-parsers-elixir))
(ess-r-mode . ,(ts-fold-parsers-r))
(go-mode . ,(ts-fold-parsers-go))
@@ -669,6 +670,17 @@ more information."
(end (1+ (tsc-node-start-position last_bracket))))
(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.
+
+For arguments NODE and OFFSET, see function `ts-fold-range-seq' for
+more information."
+ (when-let* ((param-node (tsc-get-nth-child node 4))
+ (beg (tsc-node-start-position param-node))
+ (end (1- (tsc-node-end-position node))))
+ (ts-fold--cons-add (cons beg end) offset)))
+
(defun ts-fold-range-elixir (node offset)
"Return the fold range for `function' `module' NODE in Elixir.
- [nongnu] elpa/treesit-fold 68c7954b3a 155/417: Apply more accurate c-like comment, (continued)
- [nongnu] elpa/treesit-fold 68c7954b3a 155/417: Apply more accurate c-like comment, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold b2222f0f7f 159/417: Update list, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 68d16a9bc9 166/417: Rename to ts-fold, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold d556beb204 172/417: Merge pull request #4 from rynffoll/feature/add-support-evil-toggle-fold, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 52d36972ef 218/417: chore(list): sort language alphabetically (#12), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold ea554f10e7 220/417: Fix a minor typo in ts-fold-parsers.el (#14), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold a7c29941c2 225/417: OCaml parser and first functions added (#21), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 1d690b8d06 267/417: feat(python): Support assignment string, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 78f0b0437f 278/417: docs(README.md): Mention Noir in TODO, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold c36f3ad85c 279/417: feat: Add Perl support (#66), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold be2b3dd211 275/417: feat: Add Elisp support (#63),
ELPA Syncer <=
- [nongnu] elpa/treesit-fold 323e252cf5 284/417: feat: Add Kotlin support (#70), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 8f1f182b40 307/417: perf: Speed up count matches (#88), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold c4aaf00303 326/417: fix: Render it's own window, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 0d2b177527 381/417: fix: Update rust line comment rule, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold cc31fb573b 399/417: docs: Update line-reminder config, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 6bb13a51ce 401/417: docs: Changelog, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold ef32910994 379/417: Update package desc, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 2d175b74ad 375/417: chore: Expose overlay's priority, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold b8ac9a81ca 387/417: fix: Ensure return t, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 930c5cd6de 333/417: feat: Add Mermaid support, ELPA Syncer, 2024/07/01