From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.bugs Subject: bug#58516: 28.1; add option/key to rerun current diff without whitespace changes Date: Fri, 14 Oct 2022 17:35:29 +0200 Message-ID: <87r0zaxvsu.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37423"; mail-complaints-to="usenet@ciao.gmane.io" Cc: gert To: 58516@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Oct 14 17:46:49 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ojMtd-0009U9-1O for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 14 Oct 2022 17:46:49 +0200 Original-Received: from localhost ([::1]:50824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ojMtb-0001qJ-Up for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 14 Oct 2022 11:46:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50540) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ojMjC-0002Ed-Q2 for bug-gnu-emacs@gnu.org; Fri, 14 Oct 2022 11:36:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39292) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ojMjC-0002bb-F3 for bug-gnu-emacs@gnu.org; Fri, 14 Oct 2022 11:36:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ojMjC-0007Dd-75 for bug-gnu-emacs@gnu.org; Fri, 14 Oct 2022 11:36:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Robert Pluim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 14 Oct 2022 15:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58516 X-GNU-PR-Package: emacs Original-Received: via spool by 58516-submit@debbugs.gnu.org id=B58516.166576173927714 (code B ref 58516); Fri, 14 Oct 2022 15:36:02 +0000 Original-Received: (at 58516) by debbugs.gnu.org; 14 Oct 2022 15:35:39 +0000 Original-Received: from localhost ([127.0.0.1]:38370 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ojMip-0007Cv-Cx for submit@debbugs.gnu.org; Fri, 14 Oct 2022 11:35:39 -0400 Original-Received: from mail-wr1-f41.google.com ([209.85.221.41]:36564) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ojMin-0007Cj-Hn for 58516@debbugs.gnu.org; Fri, 14 Oct 2022 11:35:37 -0400 Original-Received: by mail-wr1-f41.google.com with SMTP id j7so8165325wrr.3 for <58516@debbugs.gnu.org>; Fri, 14 Oct 2022 08:35:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=izT2Lj6HuFsbcuL2Q0lflHX90jcfDh7XUC22VFMuJXE=; b=RxyvuOf89SSe09nSyi0ClbColrUN+pxovTPltMGZk5Ha9maznHrXXWO8CuUpZbZUMA FmghQg/UZ1Wusrf3fEZN28v/VBX6ufswB+lakzCi78Ift7EycOldul3SZchjZnar4y6h nV6OaZYwrmkGNu1CzPJ9JdUzOP0Src3Q3Iw6dgrh4VHUJzq7SKEU/8nG7gfpMbRgUnYe prF+VMYxJWmr/RIqc0MPE+HCLvO/6fLwnmKr+UOwBigCqULWyDCmYm9iR/ytB6cfzjD/ i1upmvE8vyRtwzoTSZ+KZSbHhBU2ADwkvcXTak3RECGQd7xCAkwDnIxcbtjiUHflxEvr ZrWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=izT2Lj6HuFsbcuL2Q0lflHX90jcfDh7XUC22VFMuJXE=; b=DbVhoUYJ0PhqNpLHdROF77QMejGGOWCMn21o1e3Y6uPGtqtUvXgc30uixGwPbakJfa Kxgf+4GKldeknfR6JzBKCzQBXxp3M9hCZPfgP2t3XYPRpaePmHl2WMGjiCz+EpByY7oe PFEcIIRoKUM7hKfrjHLqn6wi7UJlDd0a25tw8ASMILCjlLIdK/56QCRbPlonEmszVaZj z0sgGbt6vnVnFZVwkKxFRoM3UXADN9q2+On+gfYH2t3AmALgWW056FV6LI+QepYsyAkP E8a12xkl4M69CFQTtYW7eqKV3Db1AG38fUdJ1uladbRSBMTXOEOn/p/WFIAr7O7WjSHX RqGg== X-Gm-Message-State: ACrzQf3wXp+8publwlnuW0GpTGJTu3C3E41O7fc1/wzj7EO/aQzg/voJ iWOquv9bIyv3R2lajWZEhio= X-Google-Smtp-Source: AMsMyM79AgJDeTRAOquBmn65UrUeaNfEmtx6pkB6OW4t2ylRep5VkpMpgHHlD3hCSGCKhq2HU/U9Dg== X-Received: by 2002:adf:d1ca:0:b0:231:aedc:7ece with SMTP id b10-20020adfd1ca000000b00231aedc7ecemr3992667wrd.72.1665761731362; Fri, 14 Oct 2022 08:35:31 -0700 (PDT) Original-Received: from rltb ([82.66.8.55]) by smtp.gmail.com with ESMTPSA id w12-20020a05600c474c00b003a682354f63sm1965812wmo.11.2022.10.14.08.35.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 08:35:30 -0700 (PDT) In-Reply-To: (gert via's message of "Fri, 14 Oct 2022 11:15:05 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:245458 Archived-At: >>>>> On Fri, 14 Oct 2022 11:15:05 +0000, gert via "Bug reports for GNU Emacs, the Swiss army knife of text editors" 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)