GNU bug report logs -
#58516
28.1; add option/key to rerun current diff without whitespace changes
Previous Next
Reported by: gert <gertopc <at> proton.me>
Date: Fri, 14 Oct 2022 14:55:02 UTC
Severity: normal
Tags: fixed, patch
Found in version 28.1
Fixed in version 30.1
Done: Robert Pluim <rpluim <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 58516 in the body.
You can then email your comments to 58516 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#58516
; Package
emacs
.
(Fri, 14 Oct 2022 14:55:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
gert <gertopc <at> proton.me>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 14 Oct 2022 14:55:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Sometimes, for example when you work together with others, there are meaningless whitespace changes in the diff.
In order to review these diff easier add a key to rerun the current diff without showing whitespace changes.
There is
("\C-c\C-w" . diff-ignore-whitespace-hunk)
which is useful, but incovenient to use when there are many hunks in the diff.
Add a key which does the same, but for all hunks (e.g. diff-toggle-whitespace-changes), so you can easily switch a diff buffer to one which ignores all whitespace changes.
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#58516
; Package
emacs
.
(Fri, 14 Oct 2022 15:36:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 58516 <at> debbugs.gnu.org (full text, mbox):
>>>>> 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 <at> 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)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#58516
; Package
emacs
.
(Fri, 14 Oct 2022 16:52:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 58516 <at> debbugs.gnu.org (full text, mbox):
Robert Pluim <rpluim <at> gmail.com> writes:
>
> Something like this, perhaps. I stuck it on a separate key, but we
> could put it on "C-u C-c C-w" instead.
>
Looks good. I agree that using a prefix argument is a better idea to
save some key bindings.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#58516
; Package
emacs
.
(Sat, 15 Oct 2022 10:20:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 58516 <at> debbugs.gnu.org (full text, mbox):
Robert Pluim <rpluim <at> gmail.com> writes:
> Something like this, perhaps. I stuck it on a separate key, but we
> could put it on "C-u C-c C-w" instead.
Yes, looks useful, but I'd rather have it on a prefix instead.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#58516
; Package
emacs
.
(Sat, 15 Oct 2022 19:22:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 58516 <at> debbugs.gnu.org (full text, mbox):
> +(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)))
A question about performance: would this run the diff command
for every hunk?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#58516
; Package
emacs
.
(Mon, 17 Oct 2022 08:50:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 58516 <at> debbugs.gnu.org (full text, mbox):
>>>>> On Sat, 15 Oct 2022 22:09:35 +0300, Juri Linkov <juri <at> linkov.net> said:
>> +(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)))
Juri> A question about performance: would this run the diff command
Juri> for every hunk?
Yes. I donʼt see an easy way to avoid that: we may not have actual
source files available, so we canʼt just run the diff command with
different switches over the whole file.
Robert
--
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#58516
; Package
emacs
.
(Mon, 17 Oct 2022 12:29:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 58516 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
>>>>> On Fri, 14 Oct 2022 18:51:42 +0200, Daniel Martín via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org> said:
Daniel> Robert Pluim <rpluim <at> gmail.com> writes:
>>
>> Something like this, perhaps. I stuck it on a separate key, but we
>> could put it on "C-u C-c C-w" instead.
>>
Daniel> Looks good. I agree that using a prefix argument is a better idea to
Daniel> save some key bindings.
Hey, there are *loads* of bindings available. "C-c C-w" anyone? 😺
Comments welcome
Robert
--
[0001-Teach-diff-ignore-whitespace-hunk-how-to-regenerate-.patch (text/x-diff, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#58516
; Package
emacs
.
(Mon, 17 Oct 2022 12:34:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 58516 <at> debbugs.gnu.org (full text, mbox):
Robert Pluim <rpluim <at> gmail.com> writes:
> Comments welcome
Looks good to me, but:
> +(defun diff-ignore-whitespace-hunk (whole-buffer)
> + "Re-diff the current hunk, ignoring whitespace differences.
> +With non-nil prefix arg, re-diff all the hunks."
> + (interactive "P")
That should be "&optional whole-buffer".
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#58516
; Package
emacs
.
(Mon, 17 Oct 2022 13:02:02 GMT)
Full text and
rfc822 format available.
Message #29 received at 58516 <at> debbugs.gnu.org (full text, mbox):
>>>>> On Mon, 17 Oct 2022 14:33:27 +0200, Lars Ingebrigtsen <larsi <at> gnus.org> said:
Lars> Robert Pluim <rpluim <at> gmail.com> writes:
>> Comments welcome
Lars> Looks good to me, but:
>> +(defun diff-ignore-whitespace-hunk (whole-buffer)
>> + "Re-diff the current hunk, ignoring whitespace differences.
>> +With non-nil prefix arg, re-diff all the hunks."
>> + (interactive "P")
Lars> That should be "&optional whole-buffer".
The interaction between `interactive' and &optional is one of those
things that my brain always seems to page out, so I believe you :-)
Robert
--
Added tag(s) patch.
Request was from
Stefan Kangas <stefankangas <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Sat, 12 Nov 2022 20:58:03 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#58516
; Package
emacs
.
(Wed, 15 Feb 2023 13:12:02 GMT)
Full text and
rfc822 format available.
Message #34 received at 58516 <at> debbugs.gnu.org (full text, mbox):
tags 58516 fixed
close 58516 30.1
quit
>>>>> On Sat, 15 Oct 2022 12:19:32 +0200, Lars Ingebrigtsen <larsi <at> gnus.org> said:
Lars> Robert Pluim <rpluim <at> gmail.com> writes:
>> Something like this, perhaps. I stuck it on a separate key, but we
>> could put it on "C-u C-c C-w" instead.
Lars> Yes, looks useful, but I'd rather have it on a prefix instead.
Now pushed to master (belatedly).
Robert
--
Added tag(s) fixed.
Request was from
Robert Pluim <rpluim <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Wed, 15 Feb 2023 13:12:02 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 30.1, send any further explanations to
58516 <at> debbugs.gnu.org and gert <gertopc <at> proton.me>
Request was from
Robert Pluim <rpluim <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Wed, 15 Feb 2023 13:12:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 16 Mar 2023 11:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 39 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.