From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#66061: 30.0.50; [PATCH] diff-buffer-with-file should reverse the order if the file is modified Date: Mon, 18 Sep 2023 13:47:39 +0300 Message-ID: <83cyyfg3lg.fsf@gnu.org> References: <25863.37313.113980.876021@orion.rgrjr.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40698"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 66061@debbugs.gnu.org To: Bob Rogers Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 18 12:49:06 2023 Return-path: Envelope-to: geb-bug-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 1qiBoP-000AJk-Ac for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 18 Sep 2023 12:49:05 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiBoJ-0002fW-Ue; Mon, 18 Sep 2023 06:49:00 -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 1qiBoE-0002dc-FJ for bug-gnu-emacs@gnu.org; Mon, 18 Sep 2023 06:48:54 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qiBoE-0007US-0V for bug-gnu-emacs@gnu.org; Mon, 18 Sep 2023 06:48:54 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qiBoM-00080s-3e for bug-gnu-emacs@gnu.org; Mon, 18 Sep 2023 06:49:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 18 Sep 2023 10:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66061 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 66061-submit@debbugs.gnu.org id=B66061.169503408330540 (code B ref 66061); Mon, 18 Sep 2023 10:49:02 +0000 Original-Received: (at 66061) by debbugs.gnu.org; 18 Sep 2023 10:48:03 +0000 Original-Received: from localhost ([127.0.0.1]:52180 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qiBnP-0007wV-4p for submit@debbugs.gnu.org; Mon, 18 Sep 2023 06:48:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56906) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qiBnM-0007vM-Rv for 66061@debbugs.gnu.org; Mon, 18 Sep 2023 06:48:01 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiBn9-000767-Ay; Mon, 18 Sep 2023 06:47:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=t54KLHLCAUUY+31DJkw5OiZQWjgxau/k8DmAJTeVA0I=; b=Y371cfFVxqvW y8ghrYkZvzJV3gy7R+WsLQGgXcQA4Uyse60uOTSgXaWxZt1aEFzCVqvKXqtzsexnGs3+g64iCMT5T pIRhfYnpviSwhimAmQ4+f4sKHPCclBRIyANFyuzBpPK2U9ARuVd1voUWK5QvWAeTRCtmXhmGfHleG gvWirJTz7tA9owvpxswuSnlT05hifGLS9o079Ef2M9ulBQmzh5/k7C/8grP55//eUiJENu7O4CWSk /5IAecOnGN8yhYurqT9AiF0BEPAhRamkeJyvz+WA5d85hj/VzLEupO8HYG2fDXSTrsCFXj+8oi7Li 2YNC8X8a8BVKaEs5i9pA2Q==; In-Reply-To: <25863.37313.113980.876021@orion.rgrjr.com> (message from Bob Rogers on Sun, 17 Sep 2023 16:54:41 -0700) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:270767 Archived-At: > From: Bob Rogers > Date: Sun, 17 Sep 2023 16:54:41 -0700 > > If you use diff-buffer-with-file in an unmodified buffer after the > file has changed on disk, the buffer and file are logically reversed; > the modified file is treated as the old version, and the original buffer > as the new one. It may seem like this is inconsistent, but since I am > expecting diff to show me what has changed but instead find myself > looking at the reverse, I find reading the resulting diff awkward and > somewhat jarring. > > The attached patch reverses the order of the arguments to diff only > when the buffer is unmodified. Either the file has changed on disk, in > which case it is probably newer, or it hasn't, in which case the diff > will be empty anyway so the order doesn't matter (and that saves > checking the actual file mod time). I don't think we can automatically always reverse them in this case. Here's a simple case where we shouldn't: . visit a file . make some edits . save the buffer to the file . copy from the backup file (or some other previous version) over the edited file on disk I think only the user knows what is "old" and what is "new". We should, of course, allow the user to reverse them, but we shouldn't reverse automatically.