From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#73407: [PATCH v4] bug#73407: 31.0.50; Add diff-discard-hunk Date: Tue, 24 Sep 2024 19:59:04 +0300 Organization: LINKOV.NET Message-ID: <867cb1dm3r.fsf@mail.linkov.net> References: <87jzf58g2t.fsf@zephyr.silentflame.com> <865xqleexg.fsf@mail.linkov.net> <87y13hmold.fsf@zephyr.silentflame.com> <86ikuldyy1.fsf@gnu.org> <87r0992h1n.fsf_-_@zephyr.silentflame.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33249"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) Cc: Eli Zaretskii , 73407@debbugs.gnu.org, dgutov@yandex.ru To: Sean Whitton Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 24 19:00:59 2024 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 1st8uJ-0008NU-0u for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 24 Sep 2024 19:00:59 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1st8u2-0002cD-5q; Tue, 24 Sep 2024 13:00:42 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1st8tx-0002bh-Vn for bug-gnu-emacs@gnu.org; Tue, 24 Sep 2024 13:00:40 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1st8tx-0007Hq-GY for bug-gnu-emacs@gnu.org; Tue, 24 Sep 2024 13:00:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=BaPg0emxhYUGnPnbPN8UqAQXVKzyorbKcmcvqbl87LM=; b=IaalVdvhfYpvneBJ3a3+4bDllhv4PgZo+eUv6LEBd0Avp4fHsjxqe7YdkNga3BFBvyC72mUPm5zqeGB469/q7JlTs/WHKgMiGSQX50XWIyXX4ggOEiVWaAqF/smVWH5xtY7XNOmB4rlYyjaoSgen55fhGgtxvmAz1tPxUCjrCo6Lhq4bPbU12KAp50MaxVLcQmYrTXw1wf6humR2BNDMnkEz//s9MUIEa7stV0UIR68zy4Js2hnJeZlqV/dqb2FMgPKaEiJYGtcUr74R3lMg7xdfXryl1nofMyVoXUyFAJRnto5mTSCDjPVmIVHk/XNwK8l/xLmjkGS4pyb5k/vuiQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1st8uL-0007qL-LM for bug-gnu-emacs@gnu.org; Tue, 24 Sep 2024 13:01:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 24 Sep 2024 17:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73407 X-GNU-PR-Package: emacs Original-Received: via spool by 73407-submit@debbugs.gnu.org id=B73407.172719723730078 (code B ref 73407); Tue, 24 Sep 2024 17:01:01 +0000 Original-Received: (at 73407) by debbugs.gnu.org; 24 Sep 2024 17:00:37 +0000 Original-Received: from localhost ([127.0.0.1]:56167 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1st8tw-0007p3-JV for submit@debbugs.gnu.org; Tue, 24 Sep 2024 13:00:36 -0400 Original-Received: from relay8-d.mail.gandi.net ([217.70.183.201]:46275) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1st8tu-0007i7-Rs for 73407@debbugs.gnu.org; Tue, 24 Sep 2024 13:00:35 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 0D39D1BF204; Tue, 24 Sep 2024 16:59:59 +0000 (UTC) In-Reply-To: <87r0992h1n.fsf_-_@zephyr.silentflame.com> (Sean Whitton's message of "Tue, 24 Sep 2024 16:43:48 +0100") X-GND-Sasl: juri@linkov.net 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:292351 Archived-At: >>> - (message "%d hunks failed; no buffers changed" failures))))) >>> + (message "%d hunks failed; no buffers changed" failures) >>> + failures)))) >> >> This comes from existing text, but still: what does the above say when >> there's only 1 failure? does it say "1 hunks failed"? If so, can we >> improve the handling of singular/plural here? > > I've installed a fix for that. Another variant would be to use 'ngettext'. >> I'm a little concerned about the binding. >> >> We have 'diff-hunk-kill' on M-k (and also 'k'), and this new addition is >> actually more destructive. I'm expecting users will trip over the difference >> and call one of them when they wanted to call the other. > > Yeah, and thinking about it more, it also doesn't really match what C-c > C-k does elsewhere in Emacs. I've made it C-c M-r in the attached v4. There is the existing 'C-c C-m' submap that could be used with e.g. 'C-c RET C-k'. > + (diff-reverse-direction beg end) > + (condition-case ret > + (diff-apply-buffer beg end) > + ;; Reversing the hunk is an implementation detail, so ensure the > + ;; user never sees it. > + (error (diff-reverse-direction beg end) > + (signal (car ret) (cdr ret))) > + (:success (if ret > + (diff-reverse-direction beg end) Instead of reversing the direction back and forth, it would be simpler to add another optional argument to 'diff-apply-buffer' to delegate it to the REVERSE argument of 'diff-find-source-location'.