Function: majutsu-diff-wash-hunk
majutsu-diff-wash-hunk is a natively compiled function defined in
majutsu-diff.el.
Signature
(majutsu-diff-wash-hunk FILE)
Documentation
Wrap the current hunk in a section for FILE without copying its body.
Source Code
;; Defined in /nix/store/jagqw3nms546pad0gxi5f3wsckk6pji7-emacs-packages-deps/share/emacs/site-lisp/majutsu-diff.el
(defun majutsu-diff-wash-hunk (file)
"Wrap the current hunk in a section for FILE without copying its body."
(let* ((header (buffer-substring-no-properties (line-beginning-position)
(line-end-position)))
(ranges nil)
(about nil)
(from-range nil)
(to-range nil))
(when (string-match "^@\\{2,\\} \\(.+?\\) @\\{2,\\}\\(?: \\(.*\\)\\)?$" header)
(setq about (match-string 2 header))
(setq ranges (mapcar (lambda (str)
(let ((nums (mapcar #'string-to-number
(split-string (substring str 1) ","))))
(if (= (length nums) 1)
(append nums (list 1))
nums)))
(split-string (match-string 1 header))))
(when (= (length ranges) 2)
(setq from-range (car ranges))
(setq to-range (cadr ranges))))
;; Remove original header and insert a propertized one.
(majutsu-diff--delete-line)
;; Use (file . from-range) as unique hunk identity to avoid collisions.
(magit-insert-section
(jj-hunk (cons file from-range) nil
:from-range from-range
:to-range to-range
:about about)
(magit-insert-heading
(propertize header 'font-lock-face 'magit-diff-hunk-heading))
(let ((body-start (point)))
;; Advance over hunk lines already present in the buffer.
(while (and (not (eobp))
(not (looking-at "^@@ "))
(not (looking-at "^diff --git ")))
(let ((bol (point)))
(forward-line 1)
(let ((face (cond
((eq (char-after bol) ?+) 'magit-diff-added)
((eq (char-after bol) ?-) 'magit-diff-removed)
(t 'magit-diff-context))))
(put-text-property bol (point) 'font-lock-face face))))
(when majutsu-diff-paint-whitespace
(majutsu-diff--paint-hunk-whitespace body-start (point) file))))))