[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/indent-bars 95592c1888 382/431: TS: improve Developer d
From: |
ELPA Syncer |
Subject: |
[elpa] externals/indent-bars 95592c1888 382/431: TS: improve Developer doc |
Date: |
Mon, 16 Sep 2024 12:59:52 -0400 (EDT) |
branch: externals/indent-bars
commit 95592c1888ef8ea1b7deda30943e954ac8f4c492
Author: JD Smith <93749+jdtsmith@users.noreply.github.com>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>
TS: improve Developer doc
---
indent-bars-ts.el | 63 ++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 42 insertions(+), 21 deletions(-)
diff --git a/indent-bars-ts.el b/indent-bars-ts.el
index 66efb3521c..35578ad191 100644
--- a/indent-bars-ts.el
+++ b/indent-bars-ts.el
@@ -16,29 +16,50 @@
;; For Developers:
;;
;; This file interfaces treesitter scope queries with font-lock-based
-;; bar drawing. Some of this happens during normal font-lock,
-;; querying treesitter for node information at point (typically at the
-;; beginning of the line). The scope highlight capability depends on
-;; the position of the point, and so requires some subtle interface
-;; between movement, tree-sitter, and font-lock. At any given point
-;; there is a scope range (a pair of markers) which determines how the
-;; bars get displayed. Small movements can change the scope
-;; signficantly.
+;; indent bar drawing. "Scope" is defined as the range of the
+;; innermost node covering point that matches the user-configured
+;; scope node types for the language of interest. For any given
+;; location of point, there is a scope range (a pair of markers) which
+;; helps determine how the bars get displayed. Short nodes occupying
+;; too-few lines are (optionally) not considered. A nil scope node
+;; indicates the entire file is the scope. Note that even small
+;; movements can change the scope and hence bar styling signficantly.
+
+;; The font-lock aspect does not differ much from normal (non-TS) bar
+;; drawing, except there is now an alternate set of bar styles (in-
+;; vs. out-of-scope), and bars on a single line can be either all one,
+;; all the other, or a combination of the two styles. The forms in
+;; the configured font-lock keywords (FACE eval forms) consult the
+;; current scope range to determine how to style bars on a line.
+
+;; But since bar fontification now depends not just on the text in the
+;; buffer, but on the position of point, this presents a few
+;; challenges to maintain efficiency. The adopted technique is as
+;; follows:
;;
-;; The technique is as follows:
-;;
-;; - A post-command hook sets up an idle-time callback if none exists.
-;; - In idle time, check for the innermost "scope" node at point.
-;; - If the node boundaries have changed from the last time they were
-;; saved (modulo insertion deletion changes markers can track),
-;; invalidate font-lock over the node's boundaries.
-;; - Short nodes occupying too-few lines are not considered. A nil
-;; scope node indicates the entire file is the scope.
-;; - Font-lock automatically re-applies indentation bars, consulting
-;; the saved node range to determine whether a given line is
-;; in-scope or out-of-scope.
-;;
+;; - A post-command hook sets up an idle-time callback (if none
+;; exists).
+;; - In idle time, we check for the innermost "scope" node at point.
+;; - If the scope node boundaries have changed from the last time
+;; they were saved (modulo simple marker movement), we apply a
+;; special property `indent-bars-invalid' to the union of the old
+;; and new scope regions.
+;; - This property is also added to `font-lock-extra-managed-props',
+;; and so font-lock removes these as it adds bars to modified and
+;; otherwise invalidated text.
+;; - In a `window-scroll-functions' function (see
+;; `indent-bars-ts--update-bars-on-scroll') we check the current
+;; window range for visible text marked has having invalid bars:
+;; `indent-bars-invalid' = t.
+;; - We then search for and draws bars within this text "by hand"
+;; (reusing the font-lock keywords and keyword functions).
;;
+;; Note that `window-scroll-functions' are called quite late, after
+;; font-locking, so very often (during text changes, but also when new
+;; `fontified'=nil text comes into view) this function can return
+;; quickly without doing anything, as font-lock will have handled
+;; things.
+
;; Note the shorthand substitutions for style related prefixes (slot
;; accessors and variables); see file-local-variables at the end:
;;
- [elpa] externals/indent-bars 0d684be9eb 290/431: docs: custom vars doc improvmements, (continued)
- [elpa] externals/indent-bars 0d684be9eb 290/431: docs: custom vars doc improvmements, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 8787ebc872 300/431: Increase default TS out-of-scope color blend factor to 0.15, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 7c8d680619 348/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 29005e1bd0 317/431: Increase default color blend to 0.5, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 1a851b6503 345/431: remove ts-teardown hook function on teardown, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars c12c740153 346/431: Bump version, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 0af707c007 338/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars af02883218 374/431: README improvements, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars f486b9a4c8 350/431: README: cleanup links, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars cbe88d5c7a 379/431: README: fix stray empty item, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 95592c1888 382/431: TS: improve Developer doc,
ELPA Syncer <=
- [elpa] externals/indent-bars 74c08d82fd 356/431: Update depth highlight: guard against deleted buffer, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars a1b942dde5 354/431: ts font-lock forms: set/clear as local variables, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 2216793de8 381/431: Merge branch 'main' into dev, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars b72fa098d7 415/431: ts: improve developer commentary, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 9f507d72fa 394/431: indent-bars--fontify: correct return structure, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 0aab084248 019/431: Capitalize in custom tags, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 37f3102422 022/431: specify width-frac for row-data, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 38265e96eb 018/431: remove current-depth timer, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars c228033146 024/431: current-depth-stipple support, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 54722d10a8 037/431: (re-) highlight current depth stipple on resize, ELPA Syncer, 2024/09/16