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#61396: diff mode could distinguish changed from deleted lines Date: Sun, 12 Feb 2023 19:20:53 +0200 Organization: LINKOV.NET Message-ID: <86fsbbnlaq.fsf@mail.linkov.net> References: <86y1p4m9cg.fsf@mail.linkov.net> <86bklzs2su.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16138"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: 61396@debbugs.gnu.org, rms@gnu.org To: Samuel Wales Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 12 18:24:27 2023 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 1pRG5R-00042q-PU for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 12 Feb 2023 18:24:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRG5A-0006YP-Qu; Sun, 12 Feb 2023 12:24:08 -0500 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 1pRG55-0006Xw-Bk for bug-gnu-emacs@gnu.org; Sun, 12 Feb 2023 12:24:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRG54-00058g-LN for bug-gnu-emacs@gnu.org; Sun, 12 Feb 2023 12:24:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pRG54-0002QP-Bz for bug-gnu-emacs@gnu.org; Sun, 12 Feb 2023 12:24:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 12 Feb 2023 17:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61396 X-GNU-PR-Package: emacs Original-Received: via spool by 61396-submit@debbugs.gnu.org id=B61396.16762226359290 (code B ref 61396); Sun, 12 Feb 2023 17:24:02 +0000 Original-Received: (at 61396) by debbugs.gnu.org; 12 Feb 2023 17:23:55 +0000 Original-Received: from localhost ([127.0.0.1]:46561 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pRG4w-0002Pl-Rf for submit@debbugs.gnu.org; Sun, 12 Feb 2023 12:23:55 -0500 Original-Received: from relay10.mail.gandi.net ([217.70.178.230]:51873) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pRG4v-0002PW-BH for 61396@debbugs.gnu.org; Sun, 12 Feb 2023 12:23:53 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 13889240003; Sun, 12 Feb 2023 17:23:44 +0000 (UTC) In-Reply-To: (Samuel Wales's message of "Sun, 12 Feb 2023 02:03:59 -0700") 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:255428 Archived-At: >> You can use such a heuristics that when the region with deleted lines >> borders the region with added lines this means that both regions show >> the changed lines. So adjacent regions in the hunk = changed lines, >> disconnected regions of added or deleted lines = separate >> additions/deletions. > > i'm not sure that will work with alternate presentatin f difflll. > what woul dbe good is for the internal diffing to notate not merely > additions and deleteions but also absence of addionts. a marker that > something will be deleted. no matter where. This depends on the definition of changed lines. And what is their granularity. To me and to the diff command, the changed lines form a block, and when there are some changes (additions or deletions) on lines inside that block, then the whole block of lines is declared as changed. But it seems that you want to check words on every line in the block for changes, and to categorize every line to three groups: 1. if on the line marked with the '-' indicator, all words are marked by refinement as deleted (ignoring whitespace), or there are no refinements on the standalone nonadjacent '-' line, declare the whole line as deleted; 2. if on the line marked with the '+' indicator, all words are marked by refinement as added (ignoring whitespace), or there are no refinements on the standalone nonadjacent '+' line, declare the whole line as added; 3. Otherwise, it's changed. Still it's impossible to classify lines even with such elaborate definition. For example, @@ -1,2 +3,4 @@ '(function-1 function-2 - function-3) + function-3 + function-4) You might want to consider the line with "function-4" added, but its closing paren comes from the line with "function-3", so it's a changed line, not added. Probably we can't do anything better than what the current word refinement does.