Function: yaml-font-lock-block-literals
yaml-font-lock-block-literals is a natively compiled function defined
in yaml-mode.el.
Signature
(yaml-font-lock-block-literals BOUND)
Documentation
Find lines within block literals.
Find the next line of the first (if any) block literal after point and
prior to BOUND. Returns the beginning and end of the block literal
line in the match data, as consumed by font-lock-keywords matcher
functions. The function begins by searching backwards to determine
whether or not the current line is within a block literal. This could
be time-consuming in large buffers, so the number of lines searched is
artificially limited to the value of
yaml-block-literal-search-lines.
Source Code
;; Defined in /nix/store/fxfawcfn8g3mqnf4q0lmvgvy0vp3nxrx-emacs-packages-deps/share/emacs/site-lisp/elpa/yaml-mode-20260830.2340/yaml-mode.el
(defun yaml-font-lock-block-literals (bound)
"Find lines within block literals.
Find the next line of the first (if any) block literal after point and
prior to BOUND. Returns the beginning and end of the block literal
line in the match data, as consumed by `font-lock-keywords' matcher
functions. The function begins by searching backwards to determine
whether or not the current line is within a block literal. This could
be time-consuming in large buffers, so the number of lines searched is
artificially limited to the value of
`yaml-block-literal-search-lines'."
(if (eolp) (goto-char (1+ (point))))
(unless (or (eobp) (>= (point) bound))
(let ((begin (point))
(end (min (1+ (line-end-position)) bound)))
(goto-char (line-beginning-position))
(while (and (looking-at yaml-blank-line-re)
(not (bobp)))
(forward-line -1))
(let ((nlines yaml-block-literal-search-lines)
(min-level (current-indentation)))
(forward-line -1)
(while (and (/= nlines 0)
(/= min-level 0)
(not (looking-at yaml-block-literal-re))
(not (bobp)))
(setq nlines (1- nlines))
(unless (looking-at yaml-blank-line-re)
(setq min-level (min min-level (current-indentation))))
(forward-line -1))
(when (looking-at-p " *- ")
(setq min-level (- min-level 2)))
(cond
((and (< (current-indentation) min-level)
(looking-at yaml-block-literal-re))
(goto-char end)
(put-text-property begin end 'yaml-block-literal t)
(set-match-data (list begin end))
t)
((progn
(goto-char begin)
(re-search-forward (concat yaml-block-literal-re
" *\\(.*\\)\n")
bound t))
(let ((range (nthcdr 2 (match-data))))
(put-text-property (car range) (cadr range) 'yaml-block-literal t)
(set-match-data range))
t))))))