Function: markdown-ts-toggle-checkbox
markdown-ts-toggle-checkbox is an interactive and byte-compiled
function defined in markdown-ts-mode.el.gz.
Signature
(markdown-ts-toggle-checkbox)
Documentation
Toggle the task list checkbox on the current line.
Switches between [ ] and [x].
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/markdown-ts-mode.el.gz
;;; List manipulation:
(defun markdown-ts-toggle-checkbox ()
"Toggle the task list checkbox on the current line.
Switches between `[ ]' and `[x]'."
(interactive)
(when-let* ((pos (save-excursion (back-to-indentation) (point)))
(node (treesit-node-at pos 'markdown))
(item (treesit-parent-until
node (lambda (n)
(equal (treesit-node-type n) "list_item")))))
(when-let* ((marker (seq-find
(lambda (child)
(member (treesit-node-type child)
'("task_list_marker_checked"
"task_list_marker_unchecked")))
(treesit-node-children item))))
(let ((beg (treesit-node-start marker))
(end (treesit-node-end marker))
(checked (equal (treesit-node-type marker)
"task_list_marker_checked")))
(save-excursion
(goto-char beg)
(delete-region beg end)
(insert (if checked "[ ]" "[x]")))))))