Function: majutsu-interactive--build-file-patch

majutsu-interactive--build-file-patch is a natively compiled function defined in majutsu-interactive.el.

Signature

(majutsu-interactive--build-file-patch FILE-SECTION HUNKS-WITH-SPECS &optional INVERT)

Documentation

Build patch string for FILE-SECTION with HUNKS-WITH-SPECS.

HUNKS-WITH-SPECS is list of (HUNK-SECTION SPEC [INVERT]). When INVERT is non-nil, invert selected hunks by default.

Source Code

;; Defined in /nix/store/jagqw3nms546pad0gxi5f3wsckk6pji7-emacs-packages-deps/share/emacs/site-lisp/majutsu-interactive.el
(defun majutsu-interactive--build-file-patch (file-section hunks-with-specs &optional invert)
  "Build patch string for FILE-SECTION with HUNKS-WITH-SPECS.
HUNKS-WITH-SPECS is list of (HUNK-SECTION SPEC [INVERT]).
When INVERT is non-nil, invert selected hunks by default."
  (let ((header (oref file-section header))
        (hunk-patches nil))
    (dolist (hs hunks-with-specs)
      (let* ((hunk (nth 0 hs))
             (spec (nth 1 hs))
             (hunk-invert (if (> (length hs) 2) (nth 2 hs) invert))
             (hunk-patch (majutsu-interactive--build-hunk-patch
                          hunk spec hunk-invert)))
        (when hunk-patch
          (push hunk-patch hunk-patches))))
    (when hunk-patches
      (concat header
              (mapconcat #'identity (nreverse hunk-patches) "")))))