unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Samuel Wales <samologist@gmail.com>
Cc: 61396@debbugs.gnu.org, rms@gnu.org
Subject: bug#61396: diff mode could distinguish changed from deleted lines
Date: Sun, 12 Feb 2023 19:20:53 +0200	[thread overview]
Message-ID: <86fsbbnlaq.fsf@mail.linkov.net> (raw)
In-Reply-To: <CAJcAo8ssk=OoEFLpOd1VmOHJDEkQhWxW5nfAWaEjMO9axCJhDA@mail.gmail.com> (Samuel Wales's message of "Sun, 12 Feb 2023 02:03:59 -0700")

>> 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.





  reply	other threads:[~2023-02-12 17:20 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-10  3:25 bug#61396: diff mode could distinguish changed from deleted lines Samuel Wales
2023-02-10  7:17 ` Juri Linkov
2023-02-10 23:49   ` Samuel Wales
2023-02-10 23:50     ` Samuel Wales
2023-02-10 13:58 ` Dmitry Gutov
2023-02-11  4:25 ` Richard Stallman
2023-02-11  5:07   ` Samuel Wales
2023-02-11 17:54     ` Juri Linkov
2023-02-12  0:52       ` Samuel Wales
2023-02-12  1:04         ` Dmitry Gutov
2023-02-12  1:07           ` Samuel Wales
2023-02-12  1:52             ` Dmitry Gutov
2023-02-12  2:12               ` Samuel Wales
2023-02-12  2:17                 ` Dmitry Gutov
2023-02-12  2:54                   ` Samuel Wales
2023-02-12  8:31         ` Juri Linkov
2023-02-12  9:03           ` Samuel Wales
2023-02-12 17:20             ` Juri Linkov [this message]
2023-02-12 22:16               ` Samuel Wales
2023-02-12 22:48                 ` Samuel Wales
2023-07-23  6:04                   ` Samuel Wales
2023-07-24 10:21                     ` Robert Pluim
2023-07-24 23:38                       ` Samuel Wales
2023-07-24 23:39                         ` Samuel Wales
2023-07-25  8:11                           ` Robert Pluim
2023-07-25 21:29                             ` Samuel Wales
2023-08-10 23:56                     ` Samuel Wales
2023-08-11  0:41                       ` Dmitry Gutov
2023-09-03 17:29                     ` Juri Linkov
2023-03-08 21:14 ` Samuel Wales
2023-09-04 21:06 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-04 22:38   ` Samuel Wales
2023-09-07  2:34     ` Samuel Wales
2023-09-12 22:11   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-12 22:31     ` Dmitry Gutov
2023-09-13 14:51       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-14  6:05         ` Samuel Wales
2023-09-14 22:42         ` Dmitry Gutov
2023-09-15  1:34           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-15  1:58             ` Samuel Wales
2023-09-15 10:20             ` Dmitry Gutov
2023-09-30 17:38         ` Juri Linkov
2023-09-30 18:18           ` Eli Zaretskii
2023-10-01  6:32             ` Juri Linkov
2023-10-01 15:54           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-01 18:53             ` Juri Linkov
2023-10-01 22:16               ` Samuel Wales
2023-10-02  6:48                 ` Juri Linkov
2023-10-02 16:56   ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86fsbbnlaq.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=61396@debbugs.gnu.org \
    --cc=rms@gnu.org \
    --cc=samologist@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).