diff options
| author | Robert Pluim | 2023-01-10 19:55:50 +0100 |
|---|---|---|
| committer | Robert Pluim | 2023-02-15 13:51:47 +0100 |
| commit | 571558e460059b3756f592abaaf2a9a67778db66 (patch) | |
| tree | 9d99d584bf5f9d729f83302001f01309cd354b17 /lisp/vc/diff-mode.el | |
| parent | b9ef710dd3b46bdfe7a0352873a0f2be5b9e4ce4 (diff) | |
| download | emacs-571558e460059b3756f592abaaf2a9a67778db66.tar.gz emacs-571558e460059b3756f592abaaf2a9a67778db66.zip | |
Teach 'diff-ignore-whitespace-hunk' how to regenerate all hunks
This implements the request from Bug#58516.
* lisp/vc/diff-mode.el (diff--ignore-whitespace-all-hunks): New
function. Iterate over all hunks, regenerate ignoring whitespace
changes.
(diff-ignore-whitespace-hunk): Call `diff--ignore-whitespace-all-hunks'
when called with a prefix arg.
* doc/emacs/files.texi (Diff Mode): Describe new functionality.
* etc/NEWS: Announce the change.
Diffstat (limited to 'lisp/vc/diff-mode.el')
| -rw-r--r-- | lisp/vc/diff-mode.el | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index eb01dede56e..6d8a868aa48 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el | |||
| @@ -2103,10 +2103,13 @@ For use in `add-log-current-defun-function'." | |||
| 2103 | (goto-char (+ (car pos) (cdr src))) | 2103 | (goto-char (+ (car pos) (cdr src))) |
| 2104 | (add-log-current-defun))))))) | 2104 | (add-log-current-defun))))))) |
| 2105 | 2105 | ||
| 2106 | (defun diff-ignore-whitespace-hunk () | 2106 | (defun diff-ignore-whitespace-hunk (&optional whole-buffer) |
| 2107 | "Re-diff the current hunk, ignoring whitespace differences." | 2107 | "Re-diff the current hunk, ignoring whitespace differences. |
| 2108 | (interactive) | 2108 | With non-nil prefix arg, re-diff all the hunks." |
| 2109 | (diff-refresh-hunk t)) | 2109 | (interactive "P") |
| 2110 | (if whole-buffer | ||
| 2111 | (diff--ignore-whitespace-all-hunks) | ||
| 2112 | (diff-refresh-hunk t))) | ||
| 2110 | 2113 | ||
| 2111 | (defun diff-refresh-hunk (&optional ignore-whitespace) | 2114 | (defun diff-refresh-hunk (&optional ignore-whitespace) |
| 2112 | "Re-diff the current hunk." | 2115 | "Re-diff the current hunk." |
| @@ -2299,6 +2302,16 @@ Call FUN with two args (BEG and END) for each hunk." | |||
| 2299 | (or (ignore-errors (diff-hunk-next) (point)) | 2302 | (or (ignore-errors (diff-hunk-next) (point)) |
| 2300 | max))))))))) | 2303 | max))))))))) |
| 2301 | 2304 | ||
| 2305 | ;; This doesn't use `diff--iterate-hunks', since that assumes that | ||
| 2306 | ;; hunks don't change size. | ||
| 2307 | (defun diff--ignore-whitespace-all-hunks () | ||
| 2308 | "Re-diff all the hunks, ignoring whitespace-differences." | ||
| 2309 | (save-excursion | ||
| 2310 | (goto-char (point-min)) | ||
| 2311 | (diff-hunk-next) | ||
| 2312 | (while (looking-at diff-hunk-header-re) | ||
| 2313 | (diff-refresh-hunk t)))) | ||
| 2314 | |||
| 2302 | (defun diff--font-lock-refined (max) | 2315 | (defun diff--font-lock-refined (max) |
| 2303 | "Apply hunk refinement from font-lock." | 2316 | "Apply hunk refinement from font-lock." |
| 2304 | (when (eq diff-refine 'font-lock) | 2317 | (when (eq diff-refine 'font-lock) |