Stefan Kangas <stefankangas@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Received: (at 66061) by debbugs.gnu.org; 18 Sep 2023 16:03:59 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 18 12:03:59 2023 Received: from localhost ([127.0.0.1]:54207 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qiGj8-0004Dh-RI for submit <at> debbugs.gnu.org; Mon, 18 Sep 2023 12:03:59 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:50444) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <rogers@HIDDEN>) id 1qiGj4-0004DF-77 for 66061 <at> debbugs.gnu.org; Mon, 18 Sep 2023 12:03:57 -0400 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-577f6205f42so3381012a12.1 for <66061 <at> debbugs.gnu.org>; Mon, 18 Sep 2023 09:03:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rgrjr-com.20230601.gappssmtp.com; s=20230601; t=1695053019; x=1695657819; darn=debbugs.gnu.org; h=references:in-reply-to:subject:cc:to:date:message-id :content-transfer-encoding:mime-version:from:from:to:cc:subject:date :message-id:reply-to; bh=rZrUdBObGuy6EnsYf/A1pH7LRkUWym462piqpaCwRi0=; b=ZUoXW8zyaDo1FaljHV3+dKySVhOB1g6GxmvtwkTr/xqeQQm8X8yuJGcGtoRi3hsUPL kbdkE5CGPuLUblLkBK+dC/tN1iT0tJESLsQiIVrf0ADrW8Ngqcvqo2yrwNVrZySZ0FEd O63SE4dbV4ixq/EjFZ3Ql88s76nPwP/AixHZtMYrNs9TLjccUgR3xxr+krlQlFH0hesG YzMtlLTPZi6ap8CVuuwC0k9wwydYBxQnbPdXHxR0O9xQGYB4FUE1umV42Af8iy2Q7/Xe VnEtREQdC/2qXUcN6gdrws6B2936WcuIrWHIf3WGWhFMZdFIjicrV7bLPd6ODFOpLK4N lc1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695053019; x=1695657819; h=references:in-reply-to:subject:cc:to:date:message-id :content-transfer-encoding:mime-version:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=rZrUdBObGuy6EnsYf/A1pH7LRkUWym462piqpaCwRi0=; b=EJ6+KtxnIj6cJxIZN3zEdWIyGHeOSspLwWnE3Py4YdkIa9r5LBXHABNbd7hJvLIgoR yUPRp4Q4DLFH9vzzUOaQ9Q066vsPBE4ATQlLnmD++y9BW0zdMLwykVEB0K80gL7eLOdf AZidQ9RoaAd5M+LWsydWTEE5ho7FaK59FMNOASJ8hfup2pibBAXS+cyKjFqNVzPpKXfi FvT6Dq50RJTq3LAhKMAUzdysF33kXF3a7gK+tJ2G4KugoqKDtARC3HonbhPkvYiBxY3b N3+sczDrKdp63ZnbkGxvOfikE6dj69lEF9oJYvauvKgSKaPE5aBlSQCY/VfCm6uNBWeI yKVA== X-Gm-Message-State: AOJu0YwKnR1wwYLONU92W6uTdo5jdA8U/FV364vxjQZ/19G5sBafCdQZ Ng5Awu9atXJOmGlpl8XA71bouw== X-Google-Smtp-Source: AGHT+IGjhJKzTB+4k4gL5ih8iQ93DoLJ+7l8JG4rO1EK5VjvsNFAuF8HPO3bighDR7yBs/HSjPYIHA== X-Received: by 2002:a17:90a:8c11:b0:268:557e:1848 with SMTP id a17-20020a17090a8c1100b00268557e1848mr6780259pjo.2.1695053019436; Mon, 18 Sep 2023 09:03:39 -0700 (PDT) Received: from orion.rgrjr.com ([2600:1700:7c2c:e000::22]) by smtp.gmail.com with ESMTPSA id 8-20020a17090a004800b0026b420ae167sm9942873pjb.17.2023.09.18.09.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 09:03:38 -0700 (PDT) From: Bob Rogers <rogers@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <25864.29913.674034.686550@HIDDEN> Date: Mon, 18 Sep 2023 09:03:37 -0700 To: Eli Zaretskii <eliz@HIDDEN> Subject: Re: bug#66061: 30.0.50; [PATCH] diff-buffer-with-file should reverse the order if the file is modified In-Reply-To: <83cyyfg3lg.fsf@HIDDEN> References: <25863.37313.113980.876021@HIDDEN> <83cyyfg3lg.fsf@HIDDEN> X-Mailer: VM 8.2.0b under 30.0.50 (x86_64-pc-linux-gnu) X-Spam-Score: -1.5 (-) X-Debbugs-Envelope-To: 66061 Cc: 66061 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.5 (--) From: Eli Zaretskii <eliz@HIDDEN> Date: Mon, 18 Sep 2023 13:47:39 +0300 > From: Bob Rogers <rogers@HIDDEN> > Date: Sun, 17 Sep 2023 16:54:41 -0700 > > . . . > > 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 thought of that, but figured this was a much less likely scenario, and could be ignored for the sake of getting closer to the right thing. 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. Fair enough. I suppose M-x diff-reverse-direction is not that much extra trouble. (I should probably find a keybinding for it.) -- Bob
bug-gnu-emacs@HIDDEN
:bug#66061
; Package emacs
.
Full text available.Received: (at 66061) by debbugs.gnu.org; 18 Sep 2023 10:48:03 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 18 06:48:03 2023 Received: from localhost ([127.0.0.1]:52180 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qiBnP-0007wV-4p for submit <at> debbugs.gnu.org; Mon, 18 Sep 2023 06:48:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56906) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1qiBnM-0007vM-Rv for 66061 <at> debbugs.gnu.org; Mon, 18 Sep 2023 06:48:01 -0400 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 <eliz@HIDDEN>) 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==; Date: Mon, 18 Sep 2023 13:47:39 +0300 Message-Id: <83cyyfg3lg.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Bob Rogers <rogers@HIDDEN> In-Reply-To: <25863.37313.113980.876021@HIDDEN> (message from Bob Rogers on Sun, 17 Sep 2023 16:54:41 -0700) Subject: Re: bug#66061: 30.0.50; [PATCH] diff-buffer-with-file should reverse the order if the file is modified References: <25863.37313.113980.876021@HIDDEN> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 66061 Cc: 66061 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Bob Rogers <rogers@HIDDEN> > 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.
bug-gnu-emacs@HIDDEN
:bug#66061
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 17 Sep 2023 23:55:08 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Sep 17 19:55:08 2023 Received: from localhost ([127.0.0.1]:51626 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qi1bY-0000Ya-19 for submit <at> debbugs.gnu.org; Sun, 17 Sep 2023 19:55:08 -0400 Received: from lists.gnu.org ([2001:470:142::17]:60128) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <rogers@HIDDEN>) id 1qi1bU-0000Xz-R4 for submit <at> debbugs.gnu.org; Sun, 17 Sep 2023 19:55:06 -0400 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 <rogers@HIDDEN>) id 1qi1bE-0007te-8m for bug-gnu-emacs@HIDDEN; Sun, 17 Sep 2023 19:54:48 -0400 Received: from mail-ot1-x32c.google.com ([2607:f8b0:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <rogers@HIDDEN>) id 1qi1bB-0001yD-4V for bug-gnu-emacs@HIDDEN; Sun, 17 Sep 2023 19:54:48 -0400 Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-6bd04558784so2524233a34.3 for <bug-gnu-emacs@HIDDEN>; Sun, 17 Sep 2023 16:54:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rgrjr-com.20230601.gappssmtp.com; s=20230601; t=1694994883; x=1695599683; darn=gnu.org; h=subject:to:date:message-id:content-transfer-encoding:mime-version :from:from:to:cc:subject:date:message-id:reply-to; bh=BWy6ECuKycWy2RfSOLuMLAIRkdNx+tgJQcC+tji2SYI=; b=kWeYlkuJHSYt8U8XnhKHefVvOFfAEQce7V8Jkpr+QRBbAITAWMYR7MldQnOBWVvnxX MCPZ5nE9JfBZ7CBykLk1UplEW33x92k2ww3R5neJlTff24vQUNFad3Ww3YHGQhOYe82a KdgnqFTNPjYFQRFBL7nVFztNydfWSAd/9AHvRShn0YXDFZzIwLBVK8ckloePag7i/Aep Q3z8t5Vmd7rQzLnGgrR85IJwbsbG9aYpuLEthmLIXU+klItbPZDJ3w5TuO3JSgkYKTf3 LMyUiyyTczO65vByjzV3V7WeITgVXF6p1IDXfolzLimLx/h+CVb8/Kt5tiVN4Kx29oOa n5KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694994883; x=1695599683; h=subject:to:date:message-id:content-transfer-encoding:mime-version :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BWy6ECuKycWy2RfSOLuMLAIRkdNx+tgJQcC+tji2SYI=; b=T6lWeYelBgYyWYiBufetFyjt39MWBdwJyWU7obU32i1q6LVgSHTihsGeafjEUIg54T 5Jkvw3pUQifNyMgHp30ACls8h7PIzN7g4AYJ2kuzUjs3hce46L0ZiHkfatlyXGUuG3FS fEjm/b9JK+jjFQqx4gqrOxmaRJsnwUwjRivPAX62tzCW9Mq00B6ev/RemamBYzZyjjv6 tpiRdnSbbK2mBdyYoSzghJMig7EAl94RP6Qo6SO3rFssbU2o34PR13IRX7wBMqUwom92 PpaLJcWrqbJuSujLfnNcCT9hWZMAiFN2YgjrkdAWFttOVZZRpbFXU6UEOCWYJWCCFmhF MQOw== X-Gm-Message-State: AOJu0Yw9JX7b5z8lQCpW7v9GL+h7BsOVlIsrRPqc6t9Takdhxv3PVLu4 +aqxgTzV8vicxFyR99Q27CxKnAR/evy54M381tQ= X-Google-Smtp-Source: AGHT+IHe/6nH+Ph64Q5z7ZZQXOAF3pKMQAey8VWXHeaB4gUl8yG2dUJSfDP2DkbDJaX1xcmIJKNhDw== X-Received: by 2002:a05:6830:617:b0:6b8:90cd:47b5 with SMTP id w23-20020a056830061700b006b890cd47b5mr9178331oti.7.1694994883439; Sun, 17 Sep 2023 16:54:43 -0700 (PDT) Received: from orion.rgrjr.com ([2600:1700:7c2c:e000::22]) by smtp.gmail.com with ESMTPSA id v10-20020a63ac0a000000b00563e1ef0491sm5750761pge.8.2023.09.17.16.54.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 16:54:42 -0700 (PDT) From: Bob Rogers <rogers@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="7lRsBY2lEc" Content-Transfer-Encoding: 7bit Message-ID: <25863.37313.113980.876021@HIDDEN> Date: Sun, 17 Sep 2023 16:54:41 -0700 To: bug-gnu-emacs@HIDDEN Subject: 30.0.50; [PATCH] diff-buffer-with-file should reverse the order if the file is modified X-Mailer: VM 8.2.0b under 30.0.50 (x86_64-pc-linux-gnu) Received-SPF: none client-ip=2607:f8b0:4864:20::32c; envelope-from=rogers@HIDDEN; helo=mail-ot1-x32c.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --7lRsBY2lEc Content-Type: text/plain; charset=us-ascii Content-Description: message body text Content-Transfer-Encoding: 7bit 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). If the buffer is modified, then it could be that both have changed, but then it's a tossup which should go first. Note that this doesn't affect the user experience of typing C-c C-c in the resulting diff buffer; it still takes you to the same place in the buffer. (After asking if you want to revert, every single time. Which could be the subject of another bug/enhancement.) -- Bob Rogers http://www.rgrjr.com/ ------------------------------------------------------------------------ In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.34, cairo version 1.16.0) of 2023-09-14 built on orion Repository revision: 1442f4043a7 Repository branch: rgr-smtpmail-env-from Windowing system distributor 'The X.Org Foundation', version 11.0.12101004 System Description: openSUSE Leap 15.5 Configured using: 'configure --with-dbus=no --with-gsettings=no --with-gif=ifavailable --with-tiff=no --with-gnutls=yes --with-gconf=no' Configured features: ACL CAIRO FREETYPE GIF GLIB GMP GNUTLS HARFBUZZ JPEG LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TOOLKIT_SCROLL_BARS X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix --7lRsBY2lEc Content-Type: text/x-patch; name="diff-buffer-with-file-rev-if-disk-changed-1.patch" Content-Description: Content-Disposition: inline; filename="diff-buffer-with-file-rev-if-disk-changed-1.patch" Content-Transfer-Encoding: 7bit diff --git a/lisp/vc/diff.el b/lisp/vc/diff.el index a411d98da31..dfa44fc00d6 100644 --- a/lisp/vc/diff.el +++ b/lisp/vc/diff.el @@ -266,7 +266,13 @@ diff-buffer-with-file (with-current-buffer (or (buffer-base-buffer buf) buf) (unless buffer-file-name (error "Buffer is not visiting a file")) - (diff buffer-file-name (current-buffer) nil 'noasync)))) + ;; If the buffer is unmodified, then the file version may be + ;; newer, so use the buffer as the old version. + (if (buffer-modified-p) + ;; Assume the buffer is newer (though both could be modified). + (diff buffer-file-name (current-buffer) nil 'noasync) + ;; Disk version may be newer. + (diff (current-buffer) buffer-file-name nil 'noasync))))) ;;;###autoload (defun diff-buffers (old new &optional switches no-async) --7lRsBY2lEc--
Bob Rogers <rogers@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#66061
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.