Function: indent-bars--current-indentation-depth
indent-bars--current-indentation-depth is a natively compiled function
defined in indent-bars.el.
Signature
(indent-bars--current-indentation-depth &optional ON-BAR INCLUDE-SKIP)
Documentation
Calculate current indentation depth and bar skip list.
Depth is always 1-based (independent of the value of
indent-bars-starting-column), with a depth of 1 corresponding to the
outermost bar, and a depth of 0 indicating that there is no valid
current depth.
If ON-BAR is nil, return the depth of the last visible bar on the
current line. If ON-BAR is non-nil and content on the line begins at a
column where a bar would otherwise have been drawn, report the depth of
that (undrawn) bar. If ON-BAR is the symbol context, and the first
non-blank line immediately above or below the current line is not at a
deeper indentation level (by at least one bar spacing), disable on-bar
and use the last-visible-bar depth for that line instead.
If indent-bars-no-descend-string is non-nil and point at line
beginning is inside a string, do not add bars deeper than one more than
the string's start. If it is all, do not add any bars at all. If
indent-bars-no-descend-lists is non-nil, perform the same check for
lists.
If indent-bars--update-depth-function is non-nil, it will be called
with the indentation depth (prior to the ON-BAR check), and can return
an updated depth to use.
If INCLUDE-SKIP is non-nil and some bars should be skipped, return (DEPTH . SKIP), with SKIP a list of bar numbers to skip display of.
Source Code
;; Defined in /nix/store/zkcdcnmcj3605fj09x584bf58d85brax-emacs-packages-deps/share/emacs/site-lisp/elpa/indent-bars-1.0.1/indent-bars.el
(defun indent-bars--current-indentation-depth
(&optional on-bar include-skip)
"Calculate current indentation depth and bar skip list.
Depth is always 1-based (independent of the value of
`indent-bars-starting-column'), with a depth of 1 corresponding to the
outermost bar, and a depth of 0 indicating that there is no valid
current depth.
If ON-BAR is nil, return the depth of the last visible bar on the
current line. If ON-BAR is non-nil and content on the line begins at a
column where a bar would otherwise have been drawn, report the depth of
that (undrawn) bar. If ON-BAR is the symbol `context', and the first
non-blank line immediately above or below the current line is not at a
deeper indentation level (by at least one bar spacing), disable on-bar
and use the last-visible-bar depth for that line instead.
If `indent-bars-no-descend-string' is non-nil and point at line
beginning is inside a string, do not add bars deeper than one more than
the string's start. If it is `all', do not add any bars at all. If
`indent-bars-no-descend-lists' is non-nil, perform the same check for
lists.
If `indent-bars--update-depth-function' is non-nil, it will be called
with the indentation depth (prior to the ON-BAR check), and can return
an updated depth to use.
If INCLUDE-SKIP is non-nil and some bars should be skipped,
return (DEPTH . SKIP), with SKIP a list of bar numbers to skip display
of."
(let* ((c (current-indentation))
(d (indent-bars--depth c)) ;last visible bar
ppss-ind skip dppss)
(when indent-bars--ppss
(save-excursion
(forward-line 0)
(let* ((syntax-ppss-table indent-bars-ppss-syntax-table)
(ppss (syntax-ppss)) ; moves point!
(string-start (and indent-bars-no-descend-string (nth 8 ppss)))
(list-start (and indent-bars-no-descend-lists (nth 1 ppss))))
(if (and string-start (eq indent-bars-no-descend-string 'all))
(setq d 0 c 0) ; always inhibit inside multiline strings
(when (setq ppss-ind (if (and string-start list-start)
(max string-start list-start)
(or string-start list-start)))
(goto-char ppss-ind)
(let* ((cppss (current-indentation)))
(setq dppss (1+ (indent-bars--depth cppss)))
(when (< dppss d) (setq d dppss c cppss)))))
;; Nested lists? Generate bar skip list (if requested)
(when (and include-skip list-start (> (car ppss) 1) (not string-start))
(setq skip
(cl-loop
for pos in (cdr (nreverse (nth 9 ppss)))
with depth
for last-depth = dppss then depth
do (progn (goto-char pos)
(setq depth (1+ (indent-bars--depth
(current-indentation)))))
if (> last-depth (1+ depth))
append (number-sequence (1+ depth) (1- last-depth))))))))
(when (and indent-bars--update-depth-function (not ppss-ind))
(setq d (funcall indent-bars--update-depth-function d)))
(when (and (eq on-bar 'context)
(< (indent-bars--context-indentation) (+ c indent-bars-spacing)))
(setq on-bar nil))
(when (and on-bar (= c (+ indent-bars--offset (* d indent-bars-spacing))))
(cl-incf d))
(if skip (cons d skip) d)))