From unknown Mon Aug 18 11:11:56 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#44312 <44312@debbugs.gnu.org> To: bug#44312 <44312@debbugs.gnu.org> Subject: Status: 28.0.50; PATCH: added new (diff-refresh-hunk) function Reply-To: bug#44312 <44312@debbugs.gnu.org> Date: Mon, 18 Aug 2025 18:11:56 +0000 retitle 44312 28.0.50; PATCH: added new (diff-refresh-hunk) function reassign 44312 emacs submitter 44312 Dima Kogan severity 44312 normal tag 44312 fixed thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 29 15:57:00 2020 Received: (at submit) by debbugs.gnu.org; 29 Oct 2020 19:57:00 +0000 Received: from localhost ([127.0.0.1]:55010 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kYE2d-0005yG-QW for submit@debbugs.gnu.org; Thu, 29 Oct 2020 15:57:00 -0400 Received: from lists.gnu.org ([209.51.188.17]:54176) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kYE2b-0005y9-T6 for submit@debbugs.gnu.org; Thu, 29 Oct 2020 15:56:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45830) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYE2b-0007X7-HP for bug-gnu-emacs@gnu.org; Thu, 29 Oct 2020 15:56:57 -0400 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:36347) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYE2Z-00080B-AE for bug-gnu-emacs@gnu.org; Thu, 29 Oct 2020 15:56:57 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 636B3AF1 for ; Thu, 29 Oct 2020 15:56:52 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 29 Oct 2020 15:56:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secretsauce.net; h=from:to:subject:date:message-id:mime-version:content-type; s= fm1; bh=O6ddR5qmAUQvgKrl3iPA3JalBBv0s5NN1ajFF3ULdvY=; b=SHGgDK2X xj6oLbQntLbtqezLcCZZLA7ZQZxCjYd0fsmBIOsnd6l9nTmltlNjQykt3YVbOBky g3xKMJWZeV35Vpc1KhjmBGMHluDV7npoe9cS6llnriLTYXCuXLu399x+G5qIN1Of iaFiFiNi+X7KExTLkZffZYfNTcplbJvJK5KaoIrtZ3clMhoKIOm3GRFriuBQ9oCs yMFnRVB/FzgVVyGbkly+Gx++r2QpD2DskjfwORnKVQE7MJPrmVFm8s3Pkq1XUhMw hu9K4grtr0OnVYrQ387DKEPF6oiJNU2PwlX5ETidvPrHTtzo+k5rz5ov/L1d5j4o uIoi9TE63xAq0A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=O6ddR5qmAUQvgKrl3iPA3JalBBv0s 5NN1ajFF3ULdvY=; b=TGj5J3GXDABUqtT5yRh++k7eHVo1YPdmg8b5t/M/ny78p LDOJ4DHsdJwhGStp5g2S2kQNjhSHBtBrdt0F6T6b5N1PSmZmUpjmTUpe/zStcvgT AsY2R8PiNM5ttLFere7ppylIKtKX67fVbxv2DklUBBKso72u8IdCxxOiOdp6srHP 9GfEV53+WUQIK3Y4vkr1FyFBJce5gQMNhizdshQ3FQu0RVH80WAvMglUc5mQ1TVo 3aJjlK3OuQ8zJ7BlUV/vjgLZ7Ds8oog2TzJ5dKNRp3HJJs9sFXZyJHCqY/Xw0uHp RjccVjZbshrRzzulJZBM3JJj62Q+kVma7gtuoBDGA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrleefgddufedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdlqddutddmnecujfgurhephf fvufffkfggtgesmhdtreertddttdenucfhrhhomhepffhimhgrucfmohhgrghnuceoughi mhgrsehsvggtrhgvthhsrghutggvrdhnvghtqeenucggtffrrghtthgvrhhnpeehvdekle dttdfhueeiuddtgefhgeevieduheejjeejfeejleevheelheduhfelveenucfkphepuddt jedrvddutddrvddufedrvdegfeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpeguihhmrgesshgvtghrvghtshgruhgtvgdrnhgvth X-ME-Proxy: Received: from localhost (107-210-213-243.lightspeed.irvnca.sbcglobal.net [107.210.213.243]) by mail.messagingengine.com (Postfix) with ESMTPA id 9D2B23064684 for ; Thu, 29 Oct 2020 15:56:51 -0400 (EDT) From: Dima Kogan To: bug-gnu-emacs@gnu.org Subject: 28.0.50; PATCH: added new (diff-refresh-hunk) function Date: Thu, 29 Oct 2020 12:56:50 -0700 Message-ID: <87h7qcu7p9.fsf@jpl.nasa.gov> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: none client-ip=64.147.123.19; envelope-from=dima@secretsauce.net; helo=wout3-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 15:56:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain Hi. Here's a patch to add a new function to diff-mode: (diff-refresh-hunk). I'm binding it to "C-c C-l" because it "refreshes" the hunk like C-l refreshes the screen. This is useful to me to throw out no-op pieces of a hunk, which I often get after editing the *vc-diff* buffer. For instance, I might end up with this hunk: @@ -298,12 +312,12 @@ stuff - f(x); + f(x); more stuff - g(x); + g(x); stuff I'd like to clean it up by throwing out the g(x) pieces, since they're the same, but keeping the f(x) pieces since they differ. C-c C-w would throw out both since it ignores whitespace differences, but the new C-c C-l does what I want. Thanks --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Added-new-diff-refresh-hunk-function.patch >From ef3900e44b7d9e8771278de843887998cfddd48f Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Thu, 29 Oct 2020 12:49:50 -0700 Subject: [PATCH] Added new (diff-refresh-hunk) function Just like the existing (diff-ignore-whitespace-hunk) function, it invokes the external "diff" tool to recompute the hunk, but it keeps the whitespace. Useful for throwing out no-op pieces of hunks. * lisp/vc/diff-mode.el (diff-refresh-hunk): New function --- lisp/vc/diff-mode.el | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 7c9ad25eb31..eded9dcb704 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -208,6 +208,8 @@ 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) + ;; `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' :-( ("\C-c\C-f" . next-error-follow-minor-mode)) "Keymap for `diff-mode'. See also `diff-mode-shared-map'.") @@ -244,6 +246,8 @@ diff-mode-menu :help "Split the current (unified diff) hunk at point into two hunks"] ["Ignore whitespace changes" diff-ignore-whitespace-hunk :help "Re-diff the current hunk, ignoring whitespace differences"] + ["Recompute the hunk" diff-refresh-hunk + :help "Re-diff the current hunk, keeping the whitespace differences"] ["Highlight fine changes" diff-refine-hunk :help "Highlight changes of hunk at point at a finer granularity"] ["Kill current hunk" diff-hunk-kill @@ -2045,8 +2049,13 @@ diff-current-defun (defun diff-ignore-whitespace-hunk () "Re-diff the current hunk, ignoring whitespace differences." (interactive) + (diff-refresh-hunk t)) + +(defun diff-refresh-hunk (&optional ignore-whitespace) + "Re-diff the current hunk." + (interactive) (let* ((char-offset (- (point) (diff-beginning-of-hunk t))) - (opts (pcase (char-after) (?@ "-bu") (?* "-bc") (_ "-b"))) + (opt_type (pcase (char-after) (?@ "-u") (?* "-c"))) (line-nb (and (or (looking-at "[^0-9]+\\([0-9]+\\)") (error "Can't find line number")) (string-to-number (match-string 1)))) @@ -2057,7 +2066,12 @@ diff-ignore-whitespace-hunk (file1 (make-temp-file "diff1")) (file2 (make-temp-file "diff2")) (coding-system-for-read buffer-file-coding-system) - old new) + opts old new) + (when ignore-whitespace + (setq opts '("-b"))) + (when opt_type + (setq opts (cons opt_type opts))) + (unwind-protect (save-excursion (setq old (diff-hunk-text hunk nil char-offset)) @@ -2066,8 +2080,9 @@ diff-ignore-whitespace-hunk (write-region (concat lead (car new)) nil file2 nil 'nomessage) (with-temp-buffer (let ((status - (call-process diff-command nil t nil - opts file1 file2))) + (apply 'call-process + `(,diff-command nil t nil + ,@opts ,file1 ,file2)))) (pcase status (0 nil) ;Nothing to reformat. (1 (goto-char (point-min)) -- 2.28.0.rc0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 30 09:05:06 2020 Received: (at 44312) by debbugs.gnu.org; 30 Oct 2020 13:05:06 +0000 Received: from localhost ([127.0.0.1]:56589 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kYU5a-00054c-GK for submit@debbugs.gnu.org; Fri, 30 Oct 2020 09:05:06 -0400 Received: from quimby.gnus.org ([95.216.78.240]:37544) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kYU5X-000540-W5 for 44312@debbugs.gnu.org; Fri, 30 Oct 2020 09:05:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=PfN66sVWbwFS2p0EwpH2hIflszMey3ZWUdfQ6TvxG2g=; b=sqvZ+belVb1ed21vLJ44CHm2Py 3OBr7kqnXfLw7sMCNOAlNQTgktvcNf2JPul/tAbB1SQ4z0kqyGFxM3f10A6uIjar9DXRut98lEIK4 pmvmcWCk4snPVNVM1jrTWFcMTzPfCJc7CNopgJkI8O+OA1lH659nrsTYJh7gV/y2gmuw=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kYU5O-0000JS-Pq; Fri, 30 Oct 2020 14:04:57 +0100 From: Lars Ingebrigtsen To: Dima Kogan Subject: Re: bug#44312: 28.0.50; PATCH: added new (diff-refresh-hunk) function References: <87h7qcu7p9.fsf@jpl.nasa.gov> X-Now-Playing: Noveller's _Arrow_: "Zeaxanthin" Date: Fri, 30 Oct 2020 14:04:53 +0100 In-Reply-To: <87h7qcu7p9.fsf@jpl.nasa.gov> (Dima Kogan's message of "Thu, 29 Oct 2020 12:56:50 -0700") Message-ID: <87361vj24q.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Dima Kogan writes: > I'd like to clean it up by throwing out the g(x) pieces, since they're > the same, but keeping the f(x) pieces since they differ. C-c C-w would > throw out both since it ignores whitespace differenc [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 44312 Cc: 44312@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Dima Kogan writes: > I'd like to clean it up by throwing out the g(x) pieces, since they're > the same, but keeping the f(x) pieces since they differ. C-c C-w would > throw out both since it ignores whitespace differences, but the new C-c > C-l does what I want. Thanks; applied to Emacs 28. (I added a manual change and a NEWS entry.) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 30 09:05:14 2020 Received: (at control) by debbugs.gnu.org; 30 Oct 2020 13:05:14 +0000 Received: from localhost ([127.0.0.1]:56592 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kYU5h-00054w-Ou for submit@debbugs.gnu.org; Fri, 30 Oct 2020 09:05:13 -0400 Received: from quimby.gnus.org ([95.216.78.240]:37588) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kYU5g-00054k-H0 for control@debbugs.gnu.org; Fri, 30 Oct 2020 09:05:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=j1zbIqxpsUEdj/dmfgACnmbABGDOS1wmQFpY+f3D9w4=; b=Tvt2+MpMQ41Iy91p4Af3N5qwzF 3xxjnBp2VWVVAR8o8NKiRM2J6tqocIREEV2LO0H3fW70KoIwJxsugPPUYHV8dB7WsjHlEsK/ri4dM Ai8SruxF1sclvxi5KpqRkL9/OnbZ4FwIClqNffEoQgeD2BXlhbzumkiq/EMl0tuNtfx8=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kYU5U-0000Ja-Uc for control@debbugs.gnu.org; Fri, 30 Oct 2020 14:05:07 +0100 Date: Fri, 30 Oct 2020 14:04:59 +0100 Message-Id: <871rhfj24k.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #44312 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: tags 44312 fixed close 44312 28.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 44312 fixed close 44312 28.1 quit From unknown Mon Aug 18 11:11:56 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 28 Nov 2020 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator