Function: magit-insert-headers

magit-insert-headers is a byte-compiled function defined in magit-section.el.

Signature

(magit-insert-headers HOOK)

Source Code

;; Defined in ~/.emacs.d/elpa/magit-section-20260330.1102/magit-section.el
(defun magit-insert-headers (hook)
  (let* ((header-sections nil)
         (fn (##push magit-insert-section--current header-sections)))
    (unwind-protect
        (progn
          (add-hook 'magit-insert-section-hook fn -90 t)
          (magit-run-section-hook hook)
          (when header-sections
            (insert "\n")
            ;; Make the first header into the parent of the rest.
            (when (cdr header-sections)
              (setq header-sections (nreverse header-sections))
              (let* ((1st-header (pop header-sections))
                     (header-parent (oref 1st-header parent)))
                (oset header-parent children (list 1st-header))
                (oset 1st-header children header-sections)
                (oset 1st-header content (oref (car header-sections) start))
                (oset 1st-header end (oref (car (last header-sections)) end))
                (dolist (sub-header header-sections)
                  (oset sub-header parent 1st-header))
                (magit-section-maybe-add-heading-map 1st-header)))))
      (remove-hook 'magit-insert-section-hook fn t))))