Function: majutsu-row-insert-entry

majutsu-row-insert-entry is a natively compiled function defined in majutsu-row.el.

Signature

(majutsu-row-insert-entry ENTRY COMPILED &optional BODY-INSERTER OMIT-BODY)

Documentation

Insert parsed ENTRY as a Magit section using COMPILED.

When BODY-INSERTER is non-nil, call it after the ordinary body inside the section body. When OMIT-BODY is non-nil, only BODY-INSERTER supplies body content.

Source Code

;; Defined in /nix/store/jagqw3nms546pad0gxi5f3wsckk6pji7-emacs-packages-deps/share/emacs/site-lisp/majutsu-row.el
(defun majutsu-row-insert-entry
    (entry compiled &optional body-inserter omit-body)
  "Insert parsed ENTRY as a Magit section using COMPILED.
When BODY-INSERTER is non-nil, call it after the ordinary body inside the
section body.  When OMIT-BODY is non-nil, only BODY-INSERTER supplies body
content."
  (let* ((id (majutsu-row-entry-id entry compiled))
         (section-class (majutsu-row-entry-section-class entry compiled))
         (section-value (majutsu-row-section-value entry compiled))
         (section-hide (majutsu-row-entry-section-hide entry compiled))
         (indent (or (plist-get entry :indent) 0))
         (prefixes (or (plist-get entry :heading-prefixes) (list "")))
         (last-prefix (or (car (last prefixes)) ""))
         (content-lines (majutsu-row-render-heading-content-lines
                         entry compiled t))
         (count (max (length content-lines) (length prefixes)))
         (heading-lines nil)
         (tail (majutsu-row-render-tail entry compiled t))
         (suffix-lines (plist-get entry :suffix-lines))
         (body (majutsu-row-render-body entry compiled t))
         (has-body (and (not omit-body)
                        (stringp body)
                        (not (string-empty-p (string-trim body))))))
    (cl-loop for idx below count
             do (let ((prefix (majutsu-row-propertize-decoration
                               (or (nth idx prefixes) last-prefix)
                               compiled id 'heading
                               (if (= idx 0) 'graph-prefix 'graph-carry)))
                      (line (or (nth idx content-lines) "")))
                  (push (cons prefix line) heading-lines)))
    (setq heading-lines (nreverse heading-lines))
    (majutsu-row--call-with-child-count-policy
     compiled
     (lambda ()
       (magit-insert-section ((eval section-class) section-value section-hide)
         (when heading-lines
           (majutsu-row--insert-heading-anchor-line
            (cdar heading-lines) tail id (caar heading-lines) compiled))
         (dolist (line (cdr heading-lines))
           (majutsu-row-insert-prefixed-line (cdr line) (car line)))
         (dolist (suffix-line suffix-lines)
           (pcase-let* ((`(,prefix . ,content)
                         (majutsu-row-split-prefix-line suffix-line indent))
                        (decorated-prefix
                         (majutsu-row-propertize-decoration
                          prefix compiled id 'heading 'graph-carry))
                        (decorated-content
                         (majutsu-row-propertize-content
                          content compiled id 'heading)))
             (majutsu-row-insert-prefixed-line
              decorated-content decorated-prefix)))
         (when (or has-body body-inserter)
           (magit-insert-heading)
           (magit-insert-section-body
             (when has-body
               (let ((body-prefix (majutsu-row-propertize-decoration
                                   (make-string indent ?\s)
                                   compiled id 'body 'body-prefix))
                     (start (point)))
                 (insert body)
                 (insert "\n")
                 (majutsu-row-apply-line-prefix-span
                  start (point) body-prefix)))
             (when body-inserter
               (funcall body-inserter)))))))))