Function: treesit-fontify-with-override

treesit-fontify-with-override is a byte-compiled function defined in treesit.el.gz.

Signature

(treesit-fontify-with-override START END FACE OVERRIDE &optional BOUND-START BOUND-END)

Documentation

Apply FACE to the region between START and END.

OVERRIDE can be nil, t, append, prepend, or keep. See treesit-font-lock-rules for their semantic.

If BOUND-START and BOUND-END are non-nil, only fontify the region in between them.

View in manual

Source Code

;; Defined in /usr/src/emacs/lisp/treesit.el.gz
(defun treesit-fontify-with-override
    (start end face override &optional bound-start bound-end)
  "Apply FACE to the region between START and END.
OVERRIDE can be nil, t, `append', `prepend', or `keep'.
See `treesit-font-lock-rules' for their semantic.

If BOUND-START and BOUND-END are non-nil, only fontify the region
in between them."
  (when (or (null bound-start) (null bound-end)
            (and bound-start bound-end
                 (<= bound-start end)
                 (>= bound-end start)))
    (when (and bound-start bound-end)
      (setq start (max bound-start start)
            end (min bound-end end)))
    (pcase override
      ('nil (unless (text-property-not-all start end 'face nil)
              (put-text-property start end 'face face)))
      ('t (put-text-property start end 'face face))
      ('append (font-lock-append-text-property
                start end 'face face))
      ('prepend (font-lock-prepend-text-property
                 start end 'face face))
      ('keep (font-lock-fillin-text-property
              start end 'face face))
      (_ (signal 'treesit-font-lock-error
                 (list
                  "Unrecognized value of :override option"
                  override))))))