Skip to content

Commit d144eae

Browse files
authored
refactor: Use built-in ellipsis (#24)
* refactor: Use built-in ellipses * fix compile * feat: Enable compile warn as error * changelog
1 parent a409076 commit d144eae

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
1010
* feat: Add `HEEx` support (#19)
1111
* feat: Add `EditorConfig` support (#20)
1212
* feat: Add `Janet` support (#22)
13+
* refactor: Use built-in ellipsis (#24)
1314

1415
## 0.1.0
1516
> Released Jun 22, 2024

Eask

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@
1010

1111
(script "test" "echo \"Error: no test specified\" && exit 1")
1212

13-
(source "gnu")
14-
(source "melpa")
13+
(source 'gnu)
14+
(source 'melpa)
1515

1616
(depends-on "emacs" "29.1")
1717

1818
(setq network-security-level 'low) ; see https://github.com/jcs090218/setup-emacs-windows/issues/156#issuecomment-932956432
19+
20+
(add-hook 'eask-before-compile-hook
21+
(lambda ()
22+
(setq byte-compile-error-on-warn t)))

treesit-fold.el

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
;;; Code:
3939

40+
(require 'mule-util)
4041
(require 'seq)
4142
(require 'subr-x)
4243

@@ -227,11 +228,6 @@ For example, Lua, Ruby, etc."
227228
:type 'boolean
228229
:group 'treesit-fold)
229230

230-
(defcustom treesit-fold-replacement "..."
231-
"Show this string instead of the folded text."
232-
:type 'string
233-
:group 'treesit-fold)
234-
235231
(defcustom treesit-fold-priority 30
236232
"Fold range overlay's priority."
237233
:type 'integer
@@ -409,7 +405,7 @@ This function is borrowed from `tree-sitter-node-at-point'."
409405
(overlay-put ov 'display
410406
(propertize (or (and treesit-fold-summary-show
411407
(treesit-fold-summary--get (buffer-substring beg end)))
412-
treesit-fold-replacement)
408+
(truncate-string-ellipsis))
413409
'mouse-face 'treesit-fold-replacement-mouse-face
414410
'help-echo "mouse-1: unfold this node"
415411
'keymap map))
@@ -443,7 +439,7 @@ This function is borrowed from `tree-sitter-node-at-point'."
443439
(overlay-put ov 'invisible 'treesit-fold)
444440
(overlay-put ov 'display (or (and treesit-fold-summary-show
445441
(treesit-fold-summary--get (buffer-substring beg end)))
446-
treesit-fold-replacement))
442+
(truncate-string-ellipsis)))
447443
(overlay-put ov 'face 'treesit-fold-replacement-face))
448444
(treesit-fold-indicators-refresh))
449445

@@ -800,11 +796,11 @@ more information."
800796
"Return the section NODE's end point."
801797
(let ((pt (treesit-node-end node))
802798
(children (reverse (treesit-node-children node))))
803-
(cl-some (lambda (child)
804-
(when (equal 'pair (treesit-node-type child))
805-
(setq pt (treesit-node-end child))))
806-
children)
807-
pt))
799+
(or (cl-some (lambda (child)
800+
(when (equal 'pair (treesit-node-type child))
801+
(treesit-node-end child)))
802+
children)
803+
pt)))
808804

809805
(defun treesit-fold-range-editorconfig-section (node offset)
810806
"Return the fold range for `section' NODE in EditorConfig.

0 commit comments

Comments
 (0)