[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/treesit-fold d2c13aac81 069/417: Clean compile
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/treesit-fold d2c13aac81 069/417: Clean compile |
Date: |
Mon, 1 Jul 2024 10:02:12 -0400 (EDT) |
branch: elpa/treesit-fold
commit d2c13aac811fd1168078ee033a0255908d7ce1c2
Author: Jen-Chieh Shen <jcs090218@gmail.com>
Commit: Jen-Chieh Shen <jcs090218@gmail.com>
Clean compile
---
tree-sitter-fold-parsers.el | 2 +-
tree-sitter-fold-summary.el | 6 +++++-
tree-sitter-fold.el | 47 ++++++++++++++++++++++++---------------------
3 files changed, 31 insertions(+), 24 deletions(-)
diff --git a/tree-sitter-fold-parsers.el b/tree-sitter-fold-parsers.el
index a9a31015fd..af84e475a5 100644
--- a/tree-sitter-fold-parsers.el
+++ b/tree-sitter-fold-parsers.el
@@ -65,7 +65,7 @@
(defun tree-sitter-fold-parsers-nix ()
"Rule sets for Nix."
- '((attrset . tree-sitter-fold-range-nix-attrset)
+ '((attrset . tree-sitter-fold-range-seq)
(function . tree-sitter-fold-range-nix-function)))
(defun tree-sitter-fold-parsers-python ()
diff --git a/tree-sitter-fold-summary.el b/tree-sitter-fold-summary.el
index 796c8681f5..f3f2acdc96 100644
--- a/tree-sitter-fold-summary.el
+++ b/tree-sitter-fold-summary.el
@@ -59,6 +59,10 @@ This happens only when summary length is larger than variable
summary (concat summary
tree-sitter-fold-summary-exceeded-string))))
summary)
+(defun tree-sitter-fold-summary--apply-format (summary)
+ "Return the SUMMARY that has added the summary prefix."
+ (format tree-sitter-fold-summary-format summary))
+
(defun tree-sitter-fold-summary--remove-comments (doc-str)
"Remove comments from DOC-STR."
;;(s-replace-regexp "^[ \t]*[*]")
@@ -72,7 +76,7 @@ This happens only when summary length is larger than variable
(when (integerp tree-sitter-fold-summary-max-length)
(setq summary (tree-sitter-fold-summary--keep-length summary)))
(when summary
- (setq summary (origami-summary-apply-format summary)
+ (setq summary (tree-sitter-fold-summary--apply-format summary)
summary (propertize summary 'face
'tree-sitter-fold-replacement-face)))
summary
nil ; TODO: Remove this later on
diff --git a/tree-sitter-fold.el b/tree-sitter-fold.el
index 47c0c2896b..9df8904761 100644
--- a/tree-sitter-fold.el
+++ b/tree-sitter-fold.el
@@ -124,14 +124,14 @@ the fold in a cons cell. See
`tree-sitter-fold-range-python' for an example."
(add-to-invisibility-spec '(tree-sitter-fold . t))
;; evil integration
- (if (bound-and-true-p evil-fold-list)
- (add-to-list 'evil-fold-list
- '((tree-sitter-fold-mode)
- :open tree-sitter-fold-open
- :close tree-sitter-fold-close
- :open-rec tree-sitter-fold-open-recursively
- :open-all tree-sitter-fold-open-all
- :close-all tree-sitter-fold-close-all)))
+ (when (bound-and-true-p evil-fold-list)
+ (add-to-list 'evil-fold-list
+ '((tree-sitter-fold-mode)
+ :open tree-sitter-fold-open
+ :close tree-sitter-fold-close
+ :open-rec tree-sitter-fold-open-recursively
+ :open-all tree-sitter-fold-open-all
+ :close-all tree-sitter-fold-close-all)))
(run-hooks 'tree-sitter-fold-mode-hook))
@@ -201,7 +201,7 @@ This function is borrowed from `tree-sitter-node-at-point'."
"Return the tree-sitter-fold overlay at NODE if NODE is foldable and folded.
Return nil otherwise."
(when-let* ((foldable-types (alist-get major-mode
tree-sitter-fold-foldable-node-alist))
- (_ (memq (tsc-node-type node) foldable-types))
+ ((memq (tsc-node-type node) foldable-types))
(range (tree-sitter-fold--get-fold-range node)))
(thread-last (overlays-in (car range) (cdr range))
(seq-filter (lambda (ov)
@@ -233,8 +233,7 @@ current `major-mode'. If no foldable NODE is found in
point, do nothing."
;; make sure I do not create multiple overlays for the same fold
(when-let* ((ov (tree-sitter-fold-overlay-at node)))
(delete-overlay ov))
- (tree-sitter-fold--create-overlay (tree-sitter-fold--get-fold-range
node)))
- (tree-sitter-fold-indicators-refresh)))
+ (tree-sitter-fold--create-overlay (tree-sitter-fold--get-fold-range
node)))))
;;;###autoload
(defun tree-sitter-fold-open ()
@@ -293,6 +292,16 @@ If the current syntax node is not foldable, do nothing."
(delete-overlay ov)
(tree-sitter-fold-close node)))))
+(let ((commands '(tree-sitter-fold-close
+ tree-sitter-fold-open
+ tree-sitter-fold-open-recursively
+ tree-sitter-fold-close-all
+ tree-sitter-fold-open-all
+ tree-sitter-fold-toggle)))
+ (dolist (command commands)
+ (advice-add command :after (lambda ()
+ (tree-sitter-fold-indicators-refresh)))))
+
;;
;; (@* "Languages" )
;;
@@ -303,7 +312,7 @@ If the current syntax node is not foldable, do nothing."
(end (+ (tsc-node-end-position node) -1 (cdr offset))))
(cons beg end)))
-(defun tree-sitter-fold-range-python (node offset)
+(defun tree-sitter-fold-range-python (node _offset)
"Return the fold range for `function_definition' and `class_definition'
NODE in Python."
(let* ((named-node (or (tsc-get-child-by-field node :superclasses)
@@ -315,13 +324,7 @@ NODE in Python."
(end (tsc-node-end-position node)))
(cons beg end)))
-(defun tree-sitter-fold-range-nix-attrset (node offset)
- "Return the fold range for `attrset' NODE in Nix express language."
- (let ((beg (tsc-node-end-position (tsc-get-nth-child node 0)))
- (end (1- (tsc-node-end-position node))))
- (cons beg end)))
-
-(defun tree-sitter-fold-range-nix-function (node offset)
+(defun tree-sitter-fold-range-nix-function (node _offset)
"Return the fold range for `function' NODE in Nix express language."
(let ((beg (thread-first node
(tsc-get-child-by-field :formals)
@@ -330,13 +333,13 @@ NODE in Python."
(end (tsc-node-end-position node)))
(cons beg end)))
-(defun tree-sitter-fold-range-go-type-declaration (node offset)
+(defun tree-sitter-fold-range-go-type-declaration (node _offset)
"Return the fold range for `type_declaration' NODE in Go language.
Only `struct_type' and `interface_type' nodes can be folded."
(when-let* ((type-spec-node (tsc-get-nth-child node 1))
;; the type_spec node is not named in the Go grammar
;; so ensure that the 1-th child is a type_spec node
- (_ (eq (tsc-node-type type-spec-node) 'type_spec))
+ ((eq (tsc-node-type type-spec-node) 'type_spec))
(type-node (tsc-get-child-by-field type-spec-node :type))
(type-node-type (tsc-node-type type-node)))
(cond
@@ -349,7 +352,7 @@ Only `struct_type' and `interface_type' nodes can be
folded."
(cons beg end)))
(t nil))))
-(defun tree-sitter-fold-range-go-method (node offset)
+(defun tree-sitter-fold-range-go-method (node _offset)
"Return the fold range for `method_declaration' NODE in Go language."
(let* ((named-node (or (tsc-get-child-by-field node :result)
(tsc-get-child-by-field node :parameters)))
- [nongnu] elpa/treesit-fold 6b6f30eb4a 142/417: Add emoji, (continued)
- [nongnu] elpa/treesit-fold 6b6f30eb4a 142/417: Add emoji, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 6aabbc6256 147/417: Update doc, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold e6ac78f0e2 154/417: SCALE AND CENTER, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold a806886568 161/417: Update support language list, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 2409596f33 004/417: readme: fix typo, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 362fc74774 011/417: R: fold brace_list instead, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold f0858f1dbc 009/417: add support for R, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold b3faaaa40d 015/417: support folding nix functions, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold de5ad4b2f2 063/417: Split uitl, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold d07b2bae49 065/417: Complete indicators, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold d2c13aac81 069/417: Clean compile,
ELPA Syncer <=
- [nongnu] elpa/treesit-fold 4d4526ffb3 073/417: Update core, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 2dfd8c1656 083/417: Add support lang, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 5c9981872e 095/417: Restrict one, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 2ba784bea0 093/417: Fix externals, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold f13f0c371b 102/417: Core, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 80b8e2b6dc 138/417: Fix code block syntax, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold fe9b69359c 150/417: Correct external calls, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 946eebf84a 151/417: Update do, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 38cb89733b 156/417: Link indicators mode gif, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 64bb378142 158/417: Scale to 40%, ELPA Syncer, 2024/07/01