Subject: bug#70820: [PATCH] Editable grep buffers

From: Eli Zaretskii <[email-masked]>
Date: Tue, 07 May 2024 21:08:37 +0300

> From: Visuwesh <[email-masked]>
> Date: Tue, 07 May 2024 21:55:09 +0530
> 
> Attached patch is a proof of concept for an occur-edit-mode alike for
> *grep* buffers.  It uses the new track-changes library to track the
> edits made in the *grep* buffer to then finally save these edits to the
> corresponding files.  I've tested this with:
> 
>     1. pure deletions: If you have a match that says "(cur-beg start"
>        and you change it to "(cur- start".  This is special because
>        track-changes-fetch passes equal BEG and END to
>        grep-edit--track-changes-finalise.
>     2. edits: something like "(cur-beg start" -> "(cur-beg start balh"
>        is handled like you would expect.
>     3. edits with newline: if the edit includes a newline, then that is
>        reproduced.
> 
> and what is not handled currently: deleting a match line to imply
> deletion of that line from the matched file.  I don't know how to handle
> this currently, I need to learn the library more.
> 
> There's also definitely a million more cases that I didn't anticipate
> when I wrote the logic for grep-edit--track-changes-finalise.
> 
> I'm sending the patch now to see if there's enough interest before I go
> about fixing the edge cases (there's bug#52815).  If there is enough
> interest, I will take a shot at implementing something like this for
> xref result buffers too.

Thanks for working on this.

I wonder if this could be somehow either based on or at least have the
same look-and-feel as occur-edit-mode, which provides a very similar
feature in *occur* buffers.