[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/indent-bars 77411a364c 110/431: Switch from ppss to tre
From: |
ELPA Syncer |
Subject: |
[elpa] externals/indent-bars 77411a364c 110/431: Switch from ppss to tree-sitter for string context |
Date: |
Mon, 16 Sep 2024 12:59:18 -0400 (EDT) |
branch: externals/indent-bars
commit 77411a364c72e980b7e5e63263928e2c08925fee
Author: JD Smith <93749+jdtsmith@users.noreply.github.com>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>
Switch from ppss to tree-sitter for string context
Performs better for e.g. triple-quoted strings containing individual
quote marks.
---
indent-bars.el | 48 ++++++++++++++++++++++++++----------------------
1 file changed, 26 insertions(+), 22 deletions(-)
diff --git a/indent-bars.el b/indent-bars.el
index 862c51368c..9827b5d133 100644
--- a/indent-bars.el
+++ b/indent-bars.el
@@ -353,10 +353,10 @@ Set to a list of asymbols, or an alist of language
symbols and list of string ."
:value-type (repeat :tag "Types" (string :tag "Type"))))
:group 'indent-bars)
-(defcustom indent-bars-no-descend-comments-or-string t
- "Configure bar behavior in line-spanning comments and strings.
+(defcustom indent-bars-no-descend--string t
+ "Configure bar behavior inside strings.
If non-nil, bars will go no deeper than their starting line
-inside comments & strings."
+inside multi-line strings."
:type 'boolean
:group 'indent-bars)
@@ -721,28 +721,32 @@ The TYPES are as configured in
`indent-bars-treesit-support'."
(seq-contains-p indent-bars--ts-node-types
(treesit-node-type n) #'string=))
+(defvar indent-bars--string-content "string_content")
+(defsubst indent-bars--indent-at-node (node)
+ "Return the current indentation at the start of NODE."
+ (save-excursion (goto-char (treesit-node-start node))
+ (current-indentation)))
+
(defun indent-bars--current-indentation-depth ()
- "Current indentation depth.
+ "Calculate current indentation depth.
If treesit support is enabled, searches for parent nodes with
types as specified in `indent-bars-treesit-support' for the
-current language, and, if found, limits the indentation depth to
-the parent node's, plus one."
- (let ((d (/ (current-indentation) indent-bars-spacing))
- (p (point)) scs)
- (if (and indent-bars-no-descend-comments-or-string
- (setq scs (nth 8 (syntax-ppss))))
- (min d (/ (save-excursion (goto-char scs) (current-indentation))
- indent-bars-spacing))
- (if-let ((indent-bars--ts-node-types)
- ((/= p (point-min)))
- (node (treesit-parent-until
- (treesit-node-on (1- p) p indent-bars--ts-lang)
- #'indent-bars--treesit-node-match t)))
- (min d
- (1+ (/ (save-excursion (goto-char (treesit-node-start node))
- (current-indentation))
- indent-bars-spacing)))
- d))))
+current buffer's language, and, if found, limits the indentation
+depth to the parent node's, plus one. If
+`indent-bars-no-descend-string' is non-nil, look for enclosing
+string and mark indent depth no deeper than one more than the
+starting line's depth."
+ (let* ((d (/ (current-indentation) indent-bars-spacing))
+ (p (point)))
+ (when-let (((/= p (point-min)))
+ (node (treesit-node-on (1- p) p indent-bars--ts-lang)))
+ (if (and indent-bars-no-descend-string
+ (string= (treesit-node-type node) indent-bars--string-content))
+ (min d (1+ (/ (indent-bars--indent-at-node node)
indent-bars-spacing)))
+ (if-let ((indent-bars--ts-node-types)
+ (ctx (treesit-parent-until node
#'indent-bars--treesit-node-match t)))
+ (min d (1+ (/ (indent-bars--indent-at-node ctx)
indent-bars-spacing)))
+ d)))))
;;;; No stipple (e.g. terminal)
(defvar indent-bars--no-stipple-chars nil)
- [elpa] externals/indent-bars 871dcdcce1 027/431: allow other keys for current-depth-palette, (continued)
- [elpa] externals/indent-bars 871dcdcce1 027/431: allow other keys for current-depth-palette, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 84f650e5b1 031/431: simplify stipple, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars a47382bd4b 043/431: Improve comments and remove unused arg from calculate-face-spec, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 8b97ca4864 097/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars de347fc7fd 098/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars d365f46929 050/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars c495514596 069/431: README: mention disabling font-lock for stipple testing, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars eb87a137ef 054/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars e4c4bb752a 120/431: treesit: ignore-blank-lines-types, string query, custom var refactor, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars ebd89ab245 101/431: Bump version, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 77411a364c 110/431: Switch from ppss to tree-sitter for string context,
ELPA Syncer <=
- [elpa] externals/indent-bars 7bafeb32bc 074/431: README: update with PGTK :stipple Emacs bug fix, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 579aa101be 077/431: Initial no-stipple support, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 4dc2b9e329 057/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 44d7d633fc 123/431: Small doc, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars ea53a29562 127/431: Fix unwanted extra bars on over-sufficient blank lines, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 80ca1daeef 134/431: Remove reference to vestigial skip-leftmost-column, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 55852b3cee 128/431: Minor doc improvements, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 9de7111faf 125/431: Initial tab support, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 95f2bac5d9 136/431: blank-string: fix width trailing space calculation for one bar case, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 98784d79e7 169/431: Document no-stipple-char-font-weight, ELPA Syncer, 2024/09/16