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

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

[nongnu] elpa/treesit-fold e2d6e159a9 1/2: feat: Obsolete the variable


From: ELPA Syncer
Subject: [nongnu] elpa/treesit-fold e2d6e159a9 1/2: feat: Obsolete the variable
Date: Wed, 20 Nov 2024 16:00:47 -0500 (EST)

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

    feat: Obsolete the variable
---
 treesit-fold-summary.el | 29 +++++++++++++++++++++--------
 treesit-fold.el         | 22 +++++++++++-----------
 2 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/treesit-fold-summary.el b/treesit-fold-summary.el
index 3003c672f6..c1c2212453 100644
--- a/treesit-fold-summary.el
+++ b/treesit-fold-summary.el
@@ -25,6 +25,8 @@
 
 ;;; Code:
 
+(require 'mule-util)
+
 (require 'treesit-fold-util)
 
 (defcustom treesit-fold-summary-show t
@@ -38,6 +40,15 @@
                  (integer :tag "positive integer number"))
   :group 'treesit-fold)
 
+(defcustom treesit-fold-summary-format " <S> %s "
+  "Prefix string added before summary overlay."
+  :type 'string
+  :group 'treesit-fold)
+
+;;
+;; (@* "Obsolete" )
+;;
+
 (defcustom treesit-fold-summary-exceeded-string "..."
   "String that added after display summary.
 This happens only when summary length is larger than variable
@@ -45,10 +56,11 @@ This happens only when summary length is larger than 
variable
   :type 'string
   :group 'treesit-fold)
 
-(defcustom treesit-fold-summary-format " <S> %s "
-  "Prefix string added before summary overlay."
-  :type 'string
-  :group 'treesit-fold)
+(define-obsolete-variable-alias
+  'treesit-fold-summary-exceeded-string
+  'truncate-string-ellipsis
+  "treesit-fold 0.4.0"
+  "Use built-in variable instead.")
 
 ;;
 ;; (@* "Externals" )
@@ -288,11 +300,12 @@ type of content by checking the word boundary's 
existence."
 
 (defun treesit-fold-summary--keep-length (summary)
   "Keep the SUMMARY length to `treesit-fold-summary-max-length'."
-  (let ((len-sum (length summary))
-        (len-exc (length treesit-fold-summary-exceeded-string)))
+  (let ((len-sum (length summary)))
     (when (< treesit-fold-summary-max-length len-sum)
-      (setq summary (substring summary 0 (- treesit-fold-summary-max-length 
len-exc))
-            summary (concat summary treesit-fold-summary-exceeded-string))))
+      (setq summary (truncate-string-to-width summary
+                                              treesit-fold-summary-max-length
+                                              0 nil
+                                              t))))
   summary)
 
 (defun treesit-fold-summary--apply-format (summary)
diff --git a/treesit-fold.el b/treesit-fold.el
index 3d6549107c..715193314d 100644
--- a/treesit-fold.el
+++ b/treesit-fold.el
@@ -540,7 +540,7 @@ If the current node is not folded or not foldable, do 
nothing."
   "Unfold all syntax nodes in the buffer."
   (interactive)
   (treesit-fold--ensure-ts
-    (when-let ((nodes (treesit-fold--overlays-in 'invisible 'treesit-fold)))
+    (when-let* ((nodes (treesit-fold--overlays-in 'invisible 'treesit-fold)))
       (mapc #'delete-overlay nodes)
       (run-hooks 'treesit-fold-on-fold-hook)
       t)))
@@ -637,14 +637,14 @@ START-SEQ and LAST-SEQ can be named tree-sitter nodes or 
anonomous nodes.
 If no occurence is found for START-SEQ or END-SEQ or the
 occurences overlap, then the range returned is nil."
   (when start-seq
-    (when-let ((beg-node (car (treesit-fold-find-children node start-seq)))
-               (end-node (if end-seq
-                             (car (last (treesit-fold-find-children node 
end-seq)))
-                           node))
-               (beg (treesit-node-end beg-node))
-               (end (if end-seq
-                        (treesit-node-start end-node)
-                      (1- (treesit-node-end node)))))
+    (when-let* ((beg-node (car (treesit-fold-find-children node start-seq)))
+                (end-node (if end-seq
+                              (car (last (treesit-fold-find-children node 
end-seq)))
+                            node))
+                (beg (treesit-node-end beg-node))
+                (end (if end-seq
+                         (treesit-node-start end-node)
+                       (1- (treesit-node-end node)))))
       (unless (> beg end) (treesit-fold--cons-add (cons beg end) offset)))))
 
 (defun treesit-fold-range-line-comment (node offset prefix)
@@ -1407,9 +1407,9 @@ more information."
 For arguments NODE and OFFSET, see function `treesit-fold-range-seq' for
 more information."
   (when-let* ((beg (treesit-node-start node))
-              (end (cond ((when-let ((next (treesit-node-next-sibling node)))
+              (end (cond ((when-let* ((next (treesit-node-next-sibling node)))
                             (treesit-node-start next)))
-                         ((when-let ((parent (treesit-fold-find-parent node 
"if")))
+                         ((when-let* ((parent (treesit-fold-find-parent node 
"if")))
                             (- (treesit-node-end parent) 3))))))
     (when treesit-fold-on-next-line  ; display nicely
       (setq end (treesit-fold--last-eol end)))



reply via email to

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