all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: 58516@debbugs.gnu.org
Cc: gert <gertopc@proton.me>
Subject: bug#58516: 28.1; add option/key to rerun  current diff without whitespace changes
Date: Fri, 14 Oct 2022 17:35:29 +0200	[thread overview]
Message-ID: <87r0zaxvsu.fsf@gmail.com> (raw)
In-Reply-To: <SINUhcSfiSS7hwBCbw88ire4WCbRMMXMuPmqcbpqh5jRnjMu3N1ue0p3w2T0WRreCHPTPcKpWeC-_D2lj4dULEXm_r-_jTw1edw_mB2y0Es=@proton.me> (gert via's message of "Fri, 14 Oct 2022 11:15:05 +0000")

>>>>> On Fri, 14 Oct 2022 11:15:05 +0000, gert via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org> said:

    Gert> Sometimes, for example when you work together with others, there are
    Gert> meaningless whitespace changes in the diff.

    Gert> In order to review these diff easier add a key to rerun the current
    Gert> diff without showing whitespace changes.

    Gert> There is

    Gert> ("\C-c\C-w" . diff-ignore-whitespace-hunk)

    Gert> which is useful, but incovenient to use when there are many hunks in the diff.

    Gert> Add a key which does the same, but for all hunks
    Gert> (e.g. diff-toggle-whitespace-changes), so you can easily switch a diff
    Gert> buffer to one which ignores all whitespace changes.

Something like this, perhaps. I stuck it on a separate key, but we
could put it on "C-u C-c C-w" instead.

diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index a9591c9d82..3b8178884a 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -214,6 +214,7 @@ diff-mode-map
   ;; `d' because it duplicates the context :-(  --Stef
   "C-c C-d" #'diff-unified->context
   "C-c C-w" #'diff-ignore-whitespace-hunk
+  "C-c C-W" #'diff-ignore-whitespace-all-hunks
   ;; `l' because it "refreshes" the hunk like C-l refreshes the screen
   "C-c C-l" #'diff-refresh-hunk
   "C-c C-b" #'diff-refine-hunk        ;No reason for `b' :-(
@@ -2275,10 +2276,12 @@ diff--refine-hunk
                                   (match-end 0) end
                                   nil #'diff-refine-preproc props-r props-a)))))))
 
-(defun diff--iterate-hunks (max fun)
+(defun diff--iterate-hunks (max fun &optional min)
   "Iterate over all hunks between point and MAX.
 Call FUN with two args (BEG and END) for each hunk."
   (save-excursion
+      (when min
+      (goto-char min))
     (catch 'malformed
       (let* ((beg (or (ignore-errors (diff-beginning-of-hunk))
                       (ignore-errors (diff-hunk-next) (point))
@@ -2298,6 +2301,13 @@ diff--iterate-hunks
                         (or (ignore-errors (diff-hunk-next) (point))
                             max)))))))))
 
+(defun diff-ignore-whitespace-all-hunks ()
+  "Re-diff all the hunks, ignoring whitespace-differences."
+  (interactive)
+  (diff--iterate-hunks (point-max) (lambda (_ _)
+                                     (diff-refresh-hunk t))
+                       (point-min)))
+
 (defun diff--font-lock-refined (max)
   "Apply hunk refinement from font-lock."
   (when (eq diff-refine 'font-lock)





  reply	other threads:[~2022-10-14 15:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-14 11:15 bug#58516: 28.1; add option/key to rerun current diff without whitespace changes gert via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-14 15:35 ` Robert Pluim [this message]
2022-10-14 16:51   ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-17 12:27     ` Robert Pluim
2022-10-17 12:33       ` Lars Ingebrigtsen
2022-10-17 13:01         ` Robert Pluim
2022-10-15 10:19   ` Lars Ingebrigtsen
2023-02-15 13:11     ` Robert Pluim
2022-10-15 19:09   ` Juri Linkov
2022-10-17  8:49     ` Robert Pluim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r0zaxvsu.fsf@gmail.com \
    --to=rpluim@gmail.com \
    --cc=58516@debbugs.gnu.org \
    --cc=gertopc@proton.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.