Function: markdown-ts--list-promote-or-demote
markdown-ts--list-promote-or-demote is a byte-compiled function
defined in markdown-ts-mode.el.gz.
Signature
(markdown-ts--list-promote-or-demote DEMOTE)
Documentation
Change nesting of the list item at point.
If DEMOTE is non-nil, demote (indent); otherwise promote (dedent). Ordered (numbered) list items are skipped because the grammar does not support nesting them by indentation.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/markdown-ts-mode.el.gz
(defun markdown-ts--list-promote-or-demote (demote)
"Change nesting of the list item at point.
If DEMOTE is non-nil, demote (indent); otherwise promote (dedent).
Ordered (numbered) list items are skipped because the grammar does
not support nesting them by indentation."
(when-let* ((item (markdown-ts--list-item-at-point))
(region (markdown-ts--list-item-region item))
(beg (car region))
(end (cdr region)))
(when (markdown-ts--list-ordered-item-p item)
(user-error "Ordered list items cannot be nested (grammar limitation)"))
(if demote
;; Demote: indent by marker width, only if there is a previous
;; sibling to nest under (like org-mode).
(when (treesit-node-prev-sibling item)
(indent-rigidly beg end (markdown-ts--list-marker-width item)))
;; Promote: dedent to grandparent level.
(let* ((parent-list (treesit-node-parent item))
(grandparent (and parent-list (treesit-node-parent parent-list)))
(item-col (save-excursion
(goto-char beg) (current-indentation))))
(when (and grandparent
(equal (treesit-node-type grandparent) "list_item")
(> item-col 0))
(let ((gp-col (save-excursion
(goto-char (treesit-node-start grandparent))
(current-indentation))))
(indent-rigidly beg end (- gp-col item-col))))))))