Function: markdown-ts--table-body-row-near-pos
markdown-ts--table-body-row-near-pos is a byte-compiled function
defined in markdown-ts-mode.el.gz.
Signature
(markdown-ts--table-body-row-near-pos &optional POS ABUTTING)
Documentation
Return the row near POS.
Return nil if not at a table or there is no row.
Otherwise return cons (row . in-header) where in-header is nil or t.
This is useful to insert a new row just below the header instead of just
below the first row.
If POS is nil use point.
If ABUTTING is non-nil, use (1- POS) if POS is immediately after a pipe
symbol.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/markdown-ts-mode.el.gz
(defun markdown-ts--table-body-row-near-pos (&optional pos abutting)
"Return the row near POS.
Return nil if not at a table or there is no row.
Otherwise return cons (row . in-header) where in-header is nil or t.
This is useful to insert a new row just below the header instead of just
below the first row.
If POS is nil use `point'.
If ABUTTING is non-nil, use (1- POS) if POS is immediately after a pipe
symbol."
(setq pos (or pos (point)))
(let (in-header)
(when-let* ((at-table (markdown-ts-at-table-p pos abutting))
(pos (car at-table))
(table (cdr at-table))
(cell (markdown-ts--table-node-cell nil pos abutting))
(cell-type (treesit-node-type cell))
(parent (treesit-node-parent cell))
(parent-type (treesit-node-type parent))
(lineage (list cell-type parent-type))
;; Find the first row after the header or the row at POS is
;; on and in the same table.
(row (cond ((or (member "pipe_table_header" lineage)
(member "pipe_table_delimiter_row" lineage))
(setq in-header t)
(treesit-search-forward cell "\\`pipe_table_row\\'"))
((equal cell-type "pipe_table_row")
cell)
((equal parent-type "pipe_table_row")
parent))))
(when (treesit-node-eq table (treesit-search-forward
row
"\\`pipe_table\\'" 'backward))
(cons row in-header)))))