Function: magit--add-face-text-property

magit--add-face-text-property is a byte-compiled function defined in magit-section.el.

Signature

(magit--add-face-text-property BEG END FACE &optional APPEND OBJECT ADOPT-FACE)

Documentation

Like add-face-text-property but for font-lock-face.

If optional ADOPT-FACE, then replace face with font-lock-face first. The latter is a hack, which is likely to be removed again.

Source Code

;; Defined in ~/.emacs.d/elpa/magit-section-20260330.1102/magit-section.el
(defun magit--add-face-text-property ( beg end face
                                       &optional append object adopt-face)
  "Like `add-face-text-property' but for `font-lock-face'.
If optional ADOPT-FACE, then replace `face' with `font-lock-face'
first.  The latter is a hack, which is likely to be removed again."
  (when (stringp object)
    (unless beg (setq beg 0))
    (unless end (setq end (length object))))
  (when adopt-face
    (let ((beg beg)
          (end end))
      (while (< beg end)
        (let ((pos (next-single-property-change beg 'face object end))
              (val (get-text-property beg 'face object)))
          ;; We simply assume font-lock-face is not also set.
          (put-text-property beg pos 'font-lock-face val object)
          (remove-list-of-text-properties beg pos '(face) object)
          (setq beg pos)))))
  (while (< beg end)
    (let* ((pos (next-single-property-change beg 'font-lock-face object end))
           (val (get-text-property beg 'font-lock-face object))
           (val (ensure-list val)))
      (put-text-property beg pos 'font-lock-face
                         (if append
                             (append val (list face))
                           (cons face val))
                         object)
      (setq beg pos)))
  object)