[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/treesit-fold a1b5e97fa0 132/417: Improve doc
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/treesit-fold a1b5e97fa0 132/417: Improve doc |
Date: |
Mon, 1 Jul 2024 10:02:18 -0400 (EDT) |
branch: elpa/treesit-fold
commit a1b5e97fa0599e0846099f754a516bc7a05b3cbb
Author: Jen-Chieh <jcs090218@gmail.com>
Commit: Jen-Chieh <jcs090218@gmail.com>
Improve doc
---
tree-sitter-fold-indicators.el | 50 +++++++++++++++++++++++-------------------
1 file changed, 28 insertions(+), 22 deletions(-)
diff --git a/tree-sitter-fold-indicators.el b/tree-sitter-fold-indicators.el
index 8ad012600a..8f8c177b7c 100644
--- a/tree-sitter-fold-indicators.el
+++ b/tree-sitter-fold-indicators.el
@@ -168,21 +168,23 @@
(overlay-put ov 'creator 'tree-sitter-fold-indicators)
ov))
-(defun tree-sitter-fold-indicators--create-overlays (beg end show)
- "Return a list of indicator overlays.
+(defun tree-sitter-fold-indicators--create-overlays (beg end folded)
+ "Create indicators overlays in range of BEG to END.
-Argument BEG and END are range to create indicators. Argument SHOW is the flag
-defined folded region."
+If argument FOLDED is non-nil, means the region is close/hidden (overlay
+is created); this is used to determie what indicators' bitmap to use."
(let (ov-lst)
(save-excursion
(goto-char beg)
(while (and (<= (line-beginning-position) end) (not (eobp)))
(push (tree-sitter-fold-indicators--create-overlay-at-point) ov-lst)
(forward-line 1)))
- (tree-sitter-fold-indicators--update-overlays (reverse ov-lst) show)))
+ (tree-sitter-fold-indicators--update-overlays (reverse ov-lst) folded)))
(defun tree-sitter-fold-indicators--get-priority (bitmap)
- "Get priority by BITMAP."
+ "Return the priority integer depends on the type of the BITMAP.
+
+This is a static/constant method."
(let ((prior tree-sitter-fold-indicators-priority))
(cl-case bitmap
(tree-sitter-fold-indicators-fr-plus (+ prior 2))
@@ -191,27 +193,31 @@ defined folded region."
(tree-sitter-fold-indicators-fr-end-right (+ prior 1))
(t prior))))
-(defun tree-sitter-fold-indicators--get-string (show ov bitmap)
- "Return the string properties for OV by SHOW and BITMAP."
+(defun tree-sitter-fold-indicators--get-string (folded ov bitmap)
+ "Return a string or nil for indicators overlay (OV).
+
+If argument FOLDED is nil, it must return a string so all indicators are shown
+in range. Otherwise, we should only return string only when BITMAP is the
+head (first line) of the region."
(let* ((face (or (and (functionp tree-sitter-fold-indicators-face-function)
(funcall tree-sitter-fold-indicators-face-function
(overlay-start ov)))
'tree-sitter-fold-fringe-face))
(str (propertize "." 'display `(,tree-sitter-fold-indicators-fringe
,bitmap ,face))))
- (if show str
+ (if (not folded) str
(cl-case bitmap
- (tree-sitter-fold-indicators-fr-plus str)
+ (tree-sitter-fold-indicators-fr-plus str) ; return string only in head
(tree-sitter-fold-indicators-fr-minus-tail nil)
(tree-sitter-fold-indicators-fr-end-left nil)
(tree-sitter-fold-indicators-fr-end-right nil)
(t nil)))))
-(defun tree-sitter-fold-indicators--active-ov (show ov bitmap)
+(defun tree-sitter-fold-indicators--active-ov (folded ov bitmap)
"SHOW the indicator OV with BITMAP."
(when (overlayp ov)
- (overlay-put ov 'tree-sitter-fold-indicators-active show)
+ (overlay-put ov 'tree-sitter-fold-indicators-active folded)
(overlay-put ov 'type bitmap)
(overlay-put ov 'priority (tree-sitter-fold-indicators--get-priority
bitmap))
- (overlay-put ov 'before-string (tree-sitter-fold-indicators--get-string
show ov bitmap))))
+ (overlay-put ov 'before-string (tree-sitter-fold-indicators--get-string
folded ov bitmap))))
(defun tree-sitter-fold-indicators--get-end-fringe ()
"Return end fringe bitmap according to variable
`tree-sitter-fold-indicators-fringe'."
@@ -220,7 +226,7 @@ defined folded region."
(right-fringe 'tree-sitter-fold-indicators-fr-end-right)
(t (user-error "Invalid indicators fringe type: %s"
tree-sitter-fold-indicators-fringe))))
-(defun tree-sitter-fold-indicators--update-overlays (ov-lst show)
+(defun tree-sitter-fold-indicators--update-overlays (ov-lst folded)
"SHOW indicators overlays OV-LST."
(when-let* ((len (length ov-lst))
((> len 1))
@@ -229,12 +235,12 @@ defined folded region."
(last-ov (nth len-1 ov-lst))
(index 1))
(tree-sitter-fold-indicators--active-ov
- show first-ov
- (if show 'tree-sitter-fold-indicators-fr-minus-tail
- 'tree-sitter-fold-indicators-fr-plus))
- (tree-sitter-fold-indicators--active-ov show last-ov
(tree-sitter-fold-indicators--get-end-fringe))
+ folded first-ov
+ (if folded 'tree-sitter-fold-indicators-fr-plus
+ 'tree-sitter-fold-indicators-fr-minus-tail))
+ (tree-sitter-fold-indicators--active-ov folded last-ov
(tree-sitter-fold-indicators--get-end-fringe))
(while (< index len-1)
- (tree-sitter-fold-indicators--active-ov show (nth index ov-lst)
'tree-sitter-fold-indicators-fr-center)
+ (tree-sitter-fold-indicators--active-ov folded (nth index ov-lst)
'tree-sitter-fold-indicators-fr-center)
(cl-incf index)))
ov-lst)
@@ -243,11 +249,11 @@ defined folded region."
;;
(defun tree-sitter-fold-indicators--create (node)
- "Create indicators with NODE."
+ "Create indicators using NODE."
(when-let* ((range (tree-sitter-fold--get-fold-range node))
(beg (car range)) (end (cdr range)))
- (let ((show (not (tree-sitter-fold-overlay-at node))))
- (tree-sitter-fold-indicators--create-overlays beg end show))))
+ (let ((folded (tree-sitter-fold-overlay-at node)))
+ (tree-sitter-fold-indicators--create-overlays beg end folded))))
;;;###autoload
(defun tree-sitter-fold-indicators-refresh (&rest _)
- [nongnu] elpa/treesit-fold e36498c9e1 323/417: docs: Apply new changes from line-reminder, (continued)
- [nongnu] elpa/treesit-fold e36498c9e1 323/417: docs: Apply new changes from line-reminder, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold a6c75c8373 334/417: Bump version, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold e704add10d 340/417: fix(llvm): Fix folding for LLVM's label, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 41c13ff0e2 416/417: 2 bug fix (#10), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold eb714e2c21 408/417: feat: Add Gleam support (#8), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 14e3f13f67 415/417: feat: Enhance the Gleam support (#9), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 7833eb31ab 096/417: Function void, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold ad0e036355 099/417: Core, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 862b571191 118/417: Remove def, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 44714c252a 126/417: Quote description, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold a1b5e97fa0 132/417: Improve doc,
ELPA Syncer <=
- [nongnu] elpa/treesit-fold 49aff53680 136/417: Add comment, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 5e956f74dc 148/417: Support python comment and document string, ELPA Syncer, 2024/07/01
- [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