Function: markdown-move-heading-common

markdown-move-heading-common is a byte-compiled function defined in markdown-mode.el.

Signature

(markdown-move-heading-common MOVE-FN &optional ARG ADJUST)

Documentation

Wrapper for outline-mode functions to skip false positives.

MOVE-FN is a function and ARG is its argument. For example, headings inside preformatted code blocks may match outline-regexp but should not be considered as headings. When ADJUST is non-nil, adjust the point for interactive calls to avoid leaving the point at invisible markup. This adjustment generally should only be done for interactive calls, since other functions may expect the point to be at the beginning of the regular expression.

Source Code

;; Defined in ~/.emacs.d/elpa/markdown-mode-20260321.143/markdown-mode.el
;;; Outline ===================================================================

(defun markdown-move-heading-common (move-fn &optional arg adjust)
  "Wrapper for `outline-mode' functions to skip false positives.
MOVE-FN is a function and ARG is its argument. For example,
headings inside preformatted code blocks may match
`outline-regexp' but should not be considered as headings.
When ADJUST is non-nil, adjust the point for interactive calls
to avoid leaving the point at invisible markup.  This adjustment
generally should only be done for interactive calls, since other
functions may expect the point to be at the beginning of the
regular expression."
  (let ((prev -1) (start (point)))
    (if arg (funcall move-fn arg) (funcall move-fn))
    (while (and (/= prev (point)) (markdown-code-block-at-point-p))
      (setq prev (point))
      (if arg (funcall move-fn arg) (funcall move-fn)))
    ;; Adjust point for setext headings and invisible text.
    (save-match-data
      (when (and adjust (thing-at-point-looking-at markdown-regex-header))
        (if markdown-hide-markup
            ;; Move to beginning of heading text if markup is hidden.
            (goto-char (or (match-beginning 1) (match-beginning 5)))
          ;; Move to beginning of markup otherwise.
          (goto-char (or (match-beginning 1) (match-beginning 4))))))
    (if (= (point) start) nil (point))))