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: Mon, 17 Oct 2022 14:27:42 +0200 Message-ID: <87edv6y6rl.fsf@gmail.com> References: <87r0zaxvsu.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24237"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 58516@debbugs.gnu.org, gert To: Daniel =?UTF-8?Q?Mart=C3=ADn?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 17 14:29:44 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 1okPFX-00068D-Qo for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 17 Oct 2022 14:29:43 +0200 Original-Received: from localhost ([::1]:34270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okPFW-0007MB-60 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 17 Oct 2022 08:29:42 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okPEu-0007Ha-6R for bug-gnu-emacs@gnu.org; Mon, 17 Oct 2022 08:29:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48631) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1okPEs-00005g-Eq for bug-gnu-emacs@gnu.org; Mon, 17 Oct 2022 08:29:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1okPEs-00071h-1W for bug-gnu-emacs@gnu.org; Mon, 17 Oct 2022 08:29: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: Mon, 17 Oct 2022 12:29: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.166600968426933 (code B ref 58516); Mon, 17 Oct 2022 12:29:02 +0000 Original-Received: (at 58516) by debbugs.gnu.org; 17 Oct 2022 12:28:04 +0000 Original-Received: from localhost ([127.0.0.1]:47709 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1okPDv-00070K-O3 for submit@debbugs.gnu.org; Mon, 17 Oct 2022 08:28:04 -0400 Original-Received: from mail-wm1-f50.google.com ([209.85.128.50]:54026) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1okPDi-0006zb-Sa for 58516@debbugs.gnu.org; Mon, 17 Oct 2022 08:28:02 -0400 Original-Received: by mail-wm1-f50.google.com with SMTP id e18so8535959wmq.3 for <58516@debbugs.gnu.org>; Mon, 17 Oct 2022 05:27:50 -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=oTAr3JIpdyrV6oJXtCxeA1geoZNzm7CIHI55mVf5JWI=; b=X27LurOn3ZQJ174vxqH8g1pijW+JqoxfYHDw0c6ypJ8AFa9w4kL0jJzBHywYgiuNNi i1eUAN71yerdeeYmH0LT/KSisEr7hi+vBvFlDSbsihtYeK/C6XliiVzxEBT//A2V+Vra JwsHiQ80Fclw6j3CjVSjVjhdA4pYH1XDd3VtqIXU5qyvejsdgGw6/on6B4N3HvYgshFa SAxNd3MUer0+HJ+2qlVXdjaLsRJ7UMXwJmgfoHIbmTt3kzm0xpre2VzIia16jbc3Hl7w 3TCS+hv3xSONyL4f+C/P1s7KH0Bzt1j3trMRmDvyzLKi8z6rPy7VJIP1UNAOD9SDIAbi MBSQ== 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=oTAr3JIpdyrV6oJXtCxeA1geoZNzm7CIHI55mVf5JWI=; b=wQFr1YO2TaK/cqeDHpxsK1ijHc28IdG6GXTWClQkUsnhyqDJC7r4CJytgQxxvRj2ns NCzZ7C1jtf7ia6s31zmnGjQk/IUnRJNcSc2kdtiyWJp2kVaBZtByxzkNhoXiIv8g0NWo /0lBSfQu3qXFR2CFlbHToT2TIeSZ1H/gijZKl1iTgxfduA5TKZP8Au4n4Vv9McNfOLbH k+GWma9HbWTMhWuD+jTELl9ppLpZJXtUC4FNOWBWpA0GYOfOb5HCmaF5jEe68kWKRSXq F1W66SML3k9ZCpNLaFm/zdjZuDskl3YRfyjiv48Y4WtGQx5T+GlsJ7RLlxJlRyyx0Z0V Fj6Q== X-Gm-Message-State: ACrzQf3b2hjYW6aGMxBJJe1Fn1BmmIBZKSkBa3InK1KKcUC8mdzZE5RO MAM5bMAsv5oJKMYWtjJ/RCM= X-Google-Smtp-Source: AMsMyM4a40Lw4VLBZHvoB5tRyrOtswuV+FahEUIKlfv9W9JhjKwtNvZzA55HWvlnlEfrJhQUTRE8Xw== X-Received: by 2002:a1c:740c:0:b0:3c6:eb24:c06a with SMTP id p12-20020a1c740c000000b003c6eb24c06amr7492006wmc.194.1666009664796; Mon, 17 Oct 2022 05:27:44 -0700 (PDT) Original-Received: from rltb ([82.66.8.55]) by smtp.gmail.com with ESMTPSA id n14-20020a05600c4f8e00b003b47b80cec3sm15629774wmq.42.2022.10.17.05.27.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 05:27:43 -0700 (PDT) In-Reply-To: ("Daniel =?UTF-8?Q?Mart=C3=ADn?= via \"Bug reports for GNU Emacs, the Swiss army knife of text editors\""'s message of "Fri, 14 Oct 2022 18:51:42 +0200") 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:245724 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable >>>>> On Fri, 14 Oct 2022 18:51:42 +0200, Daniel Mart=C3=ADn via "Bug repor= ts for GNU Emacs, the Swiss army knife of text editors" said: Daniel> Robert Pluim writes: >>=20 >> Something like this, perhaps. I stuck it on a separate key, but we >> could put it on "C-u C-c C-w" instead. >>=20 Daniel> Looks good. I agree that using a prefix argument is a better i= dea to Daniel> save some key bindings. Hey, there are *loads* of bindings available. "C-c C-=EF=BD=97" anyone? =F0= =9F=98=BA Comments welcome Robert --=20 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Teach-diff-ignore-whitespace-hunk-how-to-regenerate-.patch >From 8192b0ac043ce2f79189ec5473ad390fe0371dd8 Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Mon, 17 Oct 2022 14:18:23 +0200 Subject: [PATCH] Teach 'diff-ignore-whitespace-hunk' how to regenerate all hunks To: emacs-devel@gnu.org This implements the request from Bug#58516. * lisp/vc/diff-mode.el (diff-ignore-whitespace-hunk): Regenerate all the hunks when called with a prefix arg. (diff--iterate-hunks): Add optional arg for start of iteration. (diff--ignore-whitespace-all-hunks): Iterate over all hunks, regenerate ignoring whitespace. * doc/emacs/files.texi (Diff Mode): Describe change in behaviour. * etc/NEWS: Announce the change. --- doc/emacs/files.texi | 3 ++- etc/NEWS | 6 ++++++ lisp/vc/diff-mode.el | 21 ++++++++++++++++----- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index 1717c5c25b..7f8a30e9d9 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi @@ -1728,7 +1728,8 @@ Diff Mode @item C-c C-w @findex diff-ignore-whitespace-hunk -Re-generate the current hunk, disregarding changes in whitespace +Re-generate the current hunk, disregarding changes in whitespace. +With a non-@code{nil} prefix arg, re-generate all the hunks (@code{diff-ignore-whitespace-hunk}). @item C-x 4 A diff --git a/etc/NEWS b/etc/NEWS index ca857056fd..8d8f1e3b7b 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1507,6 +1507,12 @@ Sets the value of the buffer-local variable 'whitespace-style' in 'diff-mode' buffers. By default, this variable is '(face trailing)', which preserves behavior from previous Emacs versions. ++++ +*** 'diff-ignore-whitespace-hunk' can now be applied to all hunks. +When called with a non-nil prefix argument +'diff-ignore-whitespace-hunk' now iterates over all the hunks in the +current diff, regenerating them without whitespace changes. + +++ *** New user option 'diff-add-log-use-relative-names'. If non-nil insert file names in ChangeLog skeletons relative to the diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index a9591c9d82..5a8d25800c 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -2102,10 +2102,13 @@ diff-current-defun (goto-char (+ (car pos) (cdr src))) (add-log-current-defun))))))) -(defun diff-ignore-whitespace-hunk () - "Re-diff the current hunk, ignoring whitespace differences." - (interactive) - (diff-refresh-hunk t)) +(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") + (if whole-buffer + (diff--ignore-whitespace-all-hunks) + (diff-refresh-hunk t))) (defun diff-refresh-hunk (&optional ignore-whitespace) "Re-diff the current hunk." @@ -2275,10 +2278,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 +2303,12 @@ 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." + (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) -- 2.37.1.116.g9dd64cb4d3 --=-=-=--