help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: delete lines with overlays [workaround to diff mode]


From: Marcin Borkowski
Subject: Re: delete lines with overlays [workaround to diff mode]
Date: Tue, 29 Aug 2023 19:19:14 +0200
User-agent: mu4e 1.1.0; emacs 30.0.50

On 2023-08-29, at 07:32, Samuel Wales <samologist@gmail.com> wrote:

> the workaround would be to have a command that can delete
> lines with overlays in A (i.e. -).  then the REMAINING lines
> are the ambiguous lines and can be inspected without
> distraction.  they are either deleted or got changed.
>
> the problem is that i don't know how to program such a
> command.  i guess it would take a c-u to delete + lines with
> overlays instead of - lines with overlays.

It will indeed be a bit of work to code this, but not too hard.  I would
start with `(overlays-in (point-min) (point-max))' to get all the
overlays in the buffer, then iterate over that list with `mapc' and at
each overlay check if the current line begins with `-' or `+' and delete
it if so.

If that is too difficult for you, and nobody else steps in, I can help
you with that.  I'm not sure, though, if it will really help you.

What I would probably do instead would be to iterate over, say, all
"deleted" lines, and for every such line try to find an "added" line
which is equal to the "deleted" line plus some string (or strings?)
somewhere.  The latter seems to be a special case of finding a longest
common subsequence (see
https://en.wikipedia.org/wiki/Longest_common_subsequence), though I'm
not good enough in algorithms to know for sure if this is the right
approach.

Hth,

-- 
Marcin Borkowski
http://mbork.pl



reply via email to

[Prev in Thread] Current Thread [Next in Thread]