Function: php-ts-mode--parent-html-heuristic
php-ts-mode--parent-html-heuristic is a byte-compiled function defined
in php-ts-mode.el.gz.
Signature
(php-ts-mode--parent-html-heuristic NODE PARENT BOL &rest _)
Documentation
Return position based on html indentation.
Returns 0 if the NODE is after the </html>, otherwise returns the
indentation point of the last word before the NODE, plus the indentation
offset. If there is no HTML tag, it returns the beginning of the
parent. When NODE is nil call php-ts-mode--open-statement-group-heuristic.
It can be used when you want to indent PHP code relative to the HTML.
PARENT is NODE's parent, BOL is the beginning of non-whitespace
characters of the current line.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/php-ts-mode.el.gz
(defun php-ts-mode--parent-html-heuristic (node parent bol &rest _)
"Return position based on html indentation.
Returns 0 if the NODE is after the </html>, otherwise returns the
indentation point of the last word before the NODE, plus the indentation
offset. If there is no HTML tag, it returns the beginning of the
parent. When NODE is nil call `php-ts-mode--open-statement-group-heuristic'.
It can be used when you want to indent PHP code relative to the HTML.
PARENT is NODE's parent, BOL is the beginning of non-whitespace
characters of the current line."
(if (null node)
;; If NODE is nil it could be an open statement-group.
(php-ts-mode--open-statement-group-heuristic node parent bol)
(let ((html-node (treesit-search-forward node "text" t)))
(if html-node
(let ((end-html (treesit-node-end html-node)))
(save-excursion
(goto-char end-html)
(backward-word)
(back-to-indentation)
(if (search-forward "</html>" end-html t 1)
0
(+ (point) php-ts-mode-indent-offset))))
;; Maybe it's better to use bol?
(treesit-node-start parent)))))