Function: markdown-ts-table-move-row
markdown-ts-table-move-row is an interactive and byte-compiled
function defined in markdown-ts-mode.el.gz.
Signature
(markdown-ts-table-move-row &optional DOWN)
Documentation
Move the row at point up one line.
If DOWN is non-nil, or with a prefix argument, move the row down one line. If point is on the header or delimiter row, do nothing. If point is not at a table, do nothing.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/markdown-ts-mode.el.gz
(defun markdown-ts-table-move-row (&optional down)
"Move the row at point up one line.
If DOWN is non-nil, or with a prefix argument, move the row down one
line.
If point is on the header or delimiter row, do nothing.
If point is not at a table, do nothing."
(interactive)
(markdown-ts--barf-if-not-mode 'markdown-ts-table-move-row)
(setq down (or down current-prefix-arg))
(when-let* ((at-table (markdown-ts-at-table-p nil t))
(pos (car at-table))
(table (cdr at-table))
(near (markdown-ts--table-body-row-near-pos pos))
;; Bail if point is on the header or delimiter row — do
;; not silently move a body row the user did not select.
((not (cdr near)))
(row (car near)))
;; Do not move above the pipe_table_delimiter_row.
;; Do not move below the bottom of the table.
(unless (or (and (not down)
(equal (treesit-node-type
(treesit-node-prev-sibling row 'named))
"pipe_table_delimiter_row"))
(and down
(not (treesit-node-next-sibling row 'named))))
(let ((row2 (if down
(treesit-node-next-sibling row 'named)
(treesit-node-prev-sibling row 'named)))
(row-end (treesit-node-end row)))
;; TODO: Remove after bug#23903 Undo after kb differs from after M-x
(push (point) buffer-undo-list)
;; If row point is outside its source region, e.g., at eol, move
;; it inside the region for stability.
(when (>= (point) row-end)
(goto-char (max (point-min) (1- row-end))))
(transpose-regions (treesit-node-start row)
(treesit-node-end row)
(treesit-node-start row2)
(treesit-node-end row2))))))