[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/treesit-fold 07fe2d17f4 249/417: feature: Add minor-mode f
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/treesit-fold 07fe2d17f4 249/417: feature: Add minor-mode for line comment (#45) |
Date: |
Mon, 1 Jul 2024 10:02:31 -0400 (EDT) |
branch: elpa/treesit-fold
commit 07fe2d17f442325025c8f9efdb1aca8a7d49ff56
Author: Jen-Chieh Shen <jcs090218@gmail.com>
Commit: GitHub <noreply@github.com>
feature: Add minor-mode for line comment (#45)
* feature: Add minor-mode for line comment
* Update doc
* update emoji
* Fix checkdoc
---
README.md | 27 ++++++++++++++++++++++-----
etc/line-comment.gif | Bin 0 -> 498924 bytes
ts-fold.el | 18 ++++++++++++++----
3 files changed, 36 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index dd96dfae29..334642bfc5 100644
--- a/README.md
+++ b/README.md
@@ -40,6 +40,8 @@ to provide code folding based on the tree-sitter syntax tree.
- [📝 Summary](#-summary)
- [🖥 Usage](#-usage-2)
- [📝 Customization](#-customization-1)
+ - [🌫️ Line-Comment folding](#-line-comment-folding)
+ - [🖥 Usage](#-usage-3)
- [🔰 Contribute](#-contribute)
- [❓ How to add a folding parser?](#-how-to-add-a-folding-parser)
- [🔍 Where can I look for tree-sitter
node?](#-where-can-i-look-for-tree-sitter-node)
@@ -85,11 +87,12 @@ The following are the functions provided by `ts-fold-mode`
Commands for enabling `ts-fold`:
| Commands | Description
|
-| -------------------------------- |
---------------------------------------------------------------------------------------------------
|
+|----------------------------------|-----------------------------------------------------------------------------------------------------|
| `ts-fold-mode` | enable `ts-fold-mode` in the current
buffer. |
| `global-ts-fold-mode` | enable `ts-fold-mode` whenever
tree-sitter is turned on and the major mode is supported by ts-fold. |
| `ts-fold-indicators-mode` | enable ts-fold with indicators in the
current buffer. See [plugins section](#-indicators-mode). |
| `global-ts-fold-indicators-mode` | enable ts-fold with indicators globally.
See [plugins section](#-indicators-mode). |
+| `ts-fold-line-comment-mode` | enable line comment folding.
|
Commands for using `ts-fold`.
@@ -147,15 +150,15 @@ mode and the value being another alist of fold
definitions.
```elisp
;; Example of ts-fold-range-alist's structure
-'((c-mode . c-folding-definitions) ;; <language>-folding-definitions is
structured as shown below
- (css-mode . css-folding-definitions)
- (go-mode . go-folding-definitions)
+'((c-mode . c-folding-definitions) ;; <language>-folding-definitions is
structured as shown below
+ (css-mode . css-folding-definitions)
+ (go-mode . go-folding-definitions)
(scala-mode . scala-folding-definitions)
...)
;; Examle of a folding definition alist
(setq css-folding-definitions
- (block . ts-fold-range-seq)
+ (block . ts-fold-range-seq)
(comment . ts-fold-range-c-like-comment))
```
@@ -496,6 +499,20 @@ As can be seen `ts-fold-summary--generic` is a very
helpful function since it
removes the provided delimiter and returns the first line. often this will be
enough.
+### 🌫️ Line-Comment folding
+
+<p align="center">
+<img src="./etc/line-comment.gif" width="80%" height="80%"/>
+</p>
+
+This plugin makes line comment into foldable range.
+
+#### 🖥 Usage
+
+ ```
+ M-x ts-fold-line-comment-mode
+ ```
+
## 🔰 Contribute
[](http://makeapullrequest.com)
diff --git a/etc/line-comment.gif b/etc/line-comment.gif
new file mode 100644
index 0000000000..02c509a7e4
Binary files /dev/null and b/etc/line-comment.gif differ
diff --git a/ts-fold.el b/ts-fold.el
index 2995f1f2ed..ad11fd9623 100644
--- a/ts-fold.el
+++ b/ts-fold.el
@@ -124,6 +124,8 @@ the fold in a cons cell. See `ts-fold-range-python' for an
example."
;; (@* "Externals" )
;;
+(defvar ts-fold-indicators-mode)
+
(declare-function ts-fold-indicators-refresh "ts-fold-indicators.el")
;;
@@ -153,8 +155,8 @@ the fold in a cons cell. See `ts-fold-range-python' for an
example."
(ts-fold-open-all)))
(defun ts-fold--tree-sitter-trigger ()
- "Turn `ts-fold-mode' on and off alongside `tree-sitter-mode'
-when in a mode ts-fold can act on."
+ "Turn `ts-fold-mode' on and off alongside `tree-sitter-mode' when in a mode
+ts-fold can act on."
(if (and tree-sitter-mode (ts-fold-usable-mode-p))
(ts-fold-mode 1)
(ts-fold-mode -1)))
@@ -169,7 +171,7 @@ when in a mode ts-fold can act on."
;;;###autoload
(define-minor-mode global-ts-fold-mode
- "Use `ts-fold-mode' wherever possible"
+ "Use `ts-fold-mode' wherever possible."
:group 'ts-fold
:init-value nil
:lighter nil
@@ -188,6 +190,13 @@ when in a mode ts-fold can act on."
(let ((mode (or mode major-mode)))
(alist-get mode ts-fold-range-alist)))
+;;;###autoload
+(define-minor-mode ts-fold-line-comment-mode
+ "Enable line comment folding."
+ :group 'ts-fold
+ :init-value nil
+ (when ts-fold-indicators-mode (ts-fold-indicators-refresh)))
+
;;
;; (@* "Core" )
;;
@@ -399,7 +408,8 @@ For arguments NODE and OFFSET, see function
`ts-fold-range-seq' for
more information.
Argument PREFIX is the comment prefix in string."
- (when-let* ((first-node (ts-fold--continuous-node-prefix node prefix nil))
+ (when-let* ((ts-fold-line-comment-mode) ; XXX: Check enabled!?
+ (first-node (ts-fold--continuous-node-prefix node prefix nil))
(last-node (ts-fold--continuous-node-prefix node prefix t))
(prefix-len (length prefix))
(beg (+ (tsc-node-start-position first-node) prefix-len))
- [nongnu] elpa/treesit-fold 03644fb5fa 341/417: fix(indicators): Rely on range itself, (continued)
- [nongnu] elpa/treesit-fold 03644fb5fa 341/417: fix(indicators): Rely on range itself, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 6ec049b140 310/417: feat: Add Make support (#90), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 75e72c658a 332/417: feat: Add Org support, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 9b25eeeb0b 404/417: chore: Update mouse face docstring, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 6b759ca36e 402/417: Update README.org (#4), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold a9d4c2ec53 296/417: feat: Add XML support (#80), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 5c45efb2d5 316/417: Update CHANGELOG.md, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold abb1c53bd4 336/417: Bump version for next release, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 544390c602 329/417: fix: Fold line comment with same indentation, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 7fdaf447cc 245/417: Change global mode to turn on with tree-sitter (#41), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 07fe2d17f4 249/417: feature: Add minor-mode for line comment (#45),
ELPA Syncer <=
- [nongnu] elpa/treesit-fold 458903e88d 250/417: fix: Fix nil tree-sitter-node, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 6ada31e372 251/417: changelog, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold fbb5510d5c 290/417: feat: Add LaTex support (#76), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 81dc9eff92 283/417: Update CHANGELOG.md, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold f8df121f08 270/417: ci(dependabot): Maintain github-actions, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold a474fd6b42 285/417: feat: Add Jai support (#71), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 27e8f44fb6 269/417: test: Emacs 29.1, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 7110ff8943 287/417: feat: Add Scheme support (#73), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 999f295bf4 282/417: fix: Don't fold lint comment when only 1 line (#69), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold befad113c9 390/417: feat: Return node when closing, ELPA Syncer, 2024/07/01