From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Curse that hunk! Date: Wed, 11 Aug 2021 17:24:57 -0400 Message-ID: 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="878"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Aug 11 23:25:59 2021 Return-path: Envelope-to: ged-emacs-devel@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 1mDvjb-000AWu-DM for ged-emacs-devel@m.gmane-mx.org; Wed, 11 Aug 2021 23:25:59 +0200 Original-Received: from localhost ([::1]:49300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDvjZ-0000mH-EP for ged-emacs-devel@m.gmane-mx.org; Wed, 11 Aug 2021 17:25:57 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDviq-0008QZ-0Z for emacs-devel@gnu.org; Wed, 11 Aug 2021 17:25:12 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:39102) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDvim-0001k9-LU for emacs-devel@gnu.org; Wed, 11 Aug 2021 17:25:10 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 739E9803CA; Wed, 11 Aug 2021 17:25:04 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 1A7E98081D; Wed, 11 Aug 2021 17:24:59 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1628717099; bh=rtOaXBq9dVcWoL0zTFSIcI3tFVZQj3O82ncYun6+1hw=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=MjJ0SR3VEWqgcek4I9M9Qe6tA/TYy7Uy2iujkandEujn44Wa5i29JY+s/PJ+AQdT3 tRjMvFYaifbxg+oY2IFqNlTzXVJfF9QuPO1YHXfKv5tV8UfxVsLShN0UUwvGPCEZsv rV4Dc6fGQHjvTq/lWtAm3bT93TodcFKweq2pBXkCggcI5dIGMszYtUCxOTUYPNiPH2 uYP8cTkYuSv6Ns/hlOhLjwQU4e1s9xfcqdCK5vOcE82325AAj/jz1RAK1WcYuWMu3R TWqOnZMq+wOoMTDAOhWQ+2OlAEf7YsSNEQCKXeNToUPcvzQIGw9QvnGk/ri8JHm83/ Y4yHpe7XoACeg== Original-Received: from alfajor (104-222-120-40.cpe.teksavvy.com [104.222.120.40]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id CBA6D1202BE; Wed, 11 Aug 2021 17:24:58 -0400 (EDT) In-Reply-To: (Alan Mackenzie's message of "Wed, 11 Aug 2021 19:53:46 +0000") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:272334 Archived-At: Alan Mackenzie [2021-08-11 19:53:46] wrote: > Finding the point where a patch hunk's old lines fail to match the file > being patched is tedious and error prone. There surely ought to be a > Lisp program, perhaps in diff.el which would fine these differences. [...] > Surely there ought to be some facility like this in Emacs? It's been on my todo-list for quite some years to provide some command to turn a diff into an diff3 conflict (after which you can use `smerge-mode` to do the rest of the job). At some point I thought I had found my solution in the form of Wiggle https://neil.brown.name/wiggle/ but when I tried it (like 10 years ago) it either crashed or gave weird results. I suspect that a lower-tech solution that applies to a single hunk at a time and where the user provides manually the region covered by the hunk should be easy enough to write, tho maybe a bit cumbersome to use (I guess we could have a `diff-select-hunk-for-application` command that records the hunk somewhere and then a `diff-apply-selected-hunk` to use in the destination buffer). Maybe a better option is to have a command which turns the hunk into an diff3 conflict at some location that's auto-selected using a very naive/simple algorithm, and then provide smerge commands to move the resulting conflict. Stefan