From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.help Subject: Re: delete lines with overlays [workaround to diff mode] Date: Tue, 29 Aug 2023 19:19:14 +0200 Message-ID: <877cpd6a25.fsf@mbork.pl> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5888"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.1.0; emacs 30.0.50 Cc: help-gnu-emacs@gnu.org To: Samuel Wales Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 29 19:21:16 2023 Return-path: Envelope-to: geh-help-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 1qb2Oy-0001BC-AU for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 29 Aug 2023 19:21:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qb2O5-0005dP-FY; Tue, 29 Aug 2023 13:20:21 -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 1qb2Nz-0005cc-BA for help-gnu-emacs@gnu.org; Tue, 29 Aug 2023 13:20:16 -0400 Original-Received: from mail.mojserwer.eu ([195.110.48.8]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qb2NK-00007m-IK for help-gnu-emacs@gnu.org; Tue, 29 Aug 2023 13:20:06 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by mail.mojserwer.eu (Postfix) with ESMTP id 1C72C6A4F54; Tue, 29 Aug 2023 19:19:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu Original-Received: from mail.mojserwer.eu ([127.0.0.1]) by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NGhKEusmbdPj; Tue, 29 Aug 2023 19:19:19 +0200 (CEST) Original-Received: from localhost (91-227-196-3.net4me.pl [91.227.196.3]) by mail.mojserwer.eu (Postfix) with ESMTPSA id D9FB87BD12D; Tue, 29 Aug 2023 19:19:17 +0200 (CEST) In-reply-to: Received-SPF: pass client-ip=195.110.48.8; envelope-from=mbork@mbork.pl; helo=mail.mojserwer.eu X-Spam_score_int: 7 X-Spam_score: 0.7 X-Spam_bar: / X-Spam_report: (0.7 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:145018 Archived-At: On 2023-08-29, at 07:32, Samuel Wales 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