Function: markdown-cycle-atx
markdown-cycle-atx is a natively compiled function defined in
markdown-mode.el.
Signature
(markdown-cycle-atx ARG &optional REMOVE)
Documentation
Cycle ATX header markup.
Promote header (decrease level) when ARG is 1 and demote
header (increase level) if arg is -1. When REMOVE is non-nil,
remove the header when the level reaches zero and stop cycling
when it reaches six. Otherwise, perform a proper cycling through
levels one through six. Assumes match data is available for
markdown-regex-header-atx.
Source Code
;; Defined in /nix/store/p33zgg95aglc47pl6zlgs43vki0snxf8-emacs-packages-deps/share/emacs/site-lisp/elpa/markdown-mode-20260827.909/markdown-mode.el
;;; Markup Cycling ============================================================
(defun markdown-cycle-atx (arg &optional remove)
"Cycle ATX header markup.
Promote header (decrease level) when ARG is 1 and demote
header (increase level) if arg is -1. When REMOVE is non-nil,
remove the header when the level reaches zero and stop cycling
when it reaches six. Otherwise, perform a proper cycling through
levels one through six. Assumes match data is available for
`markdown-regex-header-atx'."
(let* ((old-level (length (match-string 1)))
(new-level (+ old-level arg))
(text (match-string 2)))
(when (not remove)
(setq new-level (% new-level 6))
(setq new-level (cond ((= new-level 0) 6)
((< new-level 0) (+ new-level 6))
(t new-level))))
(cond
((= new-level 0)
(markdown-unwrap-thing-at-point nil 0 2))
((<= new-level 6)
(goto-char (match-beginning 0))
(delete-region (match-beginning 0) (match-end 0))
(markdown-insert-header new-level text nil)))))