Function: markdown-ts--list-move
markdown-ts--list-move is a byte-compiled function defined in
markdown-ts-mode.el.gz.
Signature
(markdown-ts--list-move UP)
Documentation
Move the list item at point.
If UP is non-nil, move past the previous sibling; otherwise move down.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/markdown-ts-mode.el.gz
(defun markdown-ts--list-move (up)
"Move the list item at point.
If UP is non-nil, move past the previous sibling; otherwise move down."
(when-let* ((item (markdown-ts--list-item-at-point))
(sibling (if up
(treesit-node-prev-sibling item)
(treesit-node-next-sibling item))))
(when (equal (treesit-node-type sibling) "list_item")
(let* ((first (if up sibling item))
(second (if up item sibling))
(first-start (markdown-ts--list-node-bol first))
(second-start (markdown-ts--list-node-bol second))
(second-end (treesit-node-end second))
;; Extract separator between items and trailing whitespace.
(first-raw (buffer-substring first-start second-start))
(first-text (string-trim-right first-raw))
(separator (substring first-raw (length first-text)))
(second-raw (buffer-substring second-start second-end))
(second-text (string-trim-right second-raw))
(trailing (substring second-raw (length second-text)))
(line-offset (- (line-number-at-pos (point))
(line-number-at-pos
(treesit-node-start item)))))
(delete-region first-start second-end)
(goto-char first-start)
(insert second-text separator first-text trailing)
(goto-char (if up
first-start
(+ first-start (length second-text)
(length separator))))
(with-suppressed-warnings ((interactive-only next-line))
(next-line line-offset))))))