Function: markdown-ts--fill-list-item

markdown-ts--fill-list-item is a byte-compiled function defined in markdown-ts-mode.el.gz.

Signature

(markdown-ts--fill-list-item ITEM JUSTIFY)

Documentation

Fill the contents of list ITEM, preserving its indentation.

Narrows to ITEM's own paragraph content (excluding nested lists) and sets fill-prefix to align continuation lines with the start of the item's text. JUSTIFY is as in fill-paragraph.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/markdown-ts-mode.el.gz
(defun markdown-ts--fill-list-item (item justify)
  "Fill the contents of list ITEM, preserving its indentation.
Narrows to ITEM's own paragraph content (excluding nested lists)
and sets `fill-prefix' to align continuation lines with the start
of the item's text.  JUSTIFY is as in `fill-paragraph'."
  (let* ((fill-prefix (make-string (markdown-ts--list-item-text-column item)
                                   ?\s))
         ;; Find the item's own paragraph (first paragraph child).
         ;; If the item has nested lists, narrow to just the
         ;; paragraph so we don't merge nested items.
         (para (treesit-search-subtree item "\\`paragraph\\'" nil nil 1))
         (beg (treesit-node-start item))
         (end (if para
                  (treesit-node-end para)
                (treesit-node-end item)))
         ;; Use default paragraph motion inside the narrowed region
         ;; so that the inner `fill-paragraph' does not re-enter our
         ;; custom paragraph-finding logic.
         (fill-forward-paragraph-function #'forward-paragraph))
    (save-restriction
      (narrow-to-region beg end)
      (fill-paragraph justify))
    ;; Return non-nil to signal that filling has been handled,
    ;; as per the contract of `fill-paragraph-function'.
    t))