From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#23824: 25.0.95; Prevent compare one buffer with itself Date: Thu, 23 Jun 2016 18:27:04 +0300 Message-ID: <83lh1w2aev.fsf@gnu.org> References: <83wplh45fw.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1466696302 13450 80.91.229.3 (23 Jun 2016 15:38:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 23 Jun 2016 15:38:22 +0000 (UTC) Cc: 23824@debbugs.gnu.org To: Tino Calancha Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jun 23 17:38:11 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bG6hm-0001Ra-1v for geb-bug-gnu-emacs@m.gmane.org; Thu, 23 Jun 2016 17:38:10 +0200 Original-Received: from localhost ([::1]:37442 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bG6hl-0001mn-8o for geb-bug-gnu-emacs@m.gmane.org; Thu, 23 Jun 2016 11:38:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bG6Z1-0000Qp-Nd for bug-gnu-emacs@gnu.org; Thu, 23 Jun 2016 11:29:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bG6Yw-0008I6-J0 for bug-gnu-emacs@gnu.org; Thu, 23 Jun 2016 11:29:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40492) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bG6Yw-0008I2-FC for bug-gnu-emacs@gnu.org; Thu, 23 Jun 2016 11:29:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bG6Yw-0004yJ-BA for bug-gnu-emacs@gnu.org; Thu, 23 Jun 2016 11:29: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: Thu, 23 Jun 2016 15:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23824 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23824-submit@debbugs.gnu.org id=B23824.146669569619035 (code B ref 23824); Thu, 23 Jun 2016 15:29:02 +0000 Original-Received: (at 23824) by debbugs.gnu.org; 23 Jun 2016 15:28:16 +0000 Original-Received: from localhost ([127.0.0.1]:52825 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bG6YC-0004ww-E1 for submit@debbugs.gnu.org; Thu, 23 Jun 2016 11:28:16 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:58625) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bG6YB-0004wl-7j for 23824@debbugs.gnu.org; Thu, 23 Jun 2016 11:28:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bG6Y0-0007un-L9 for 23824@debbugs.gnu.org; Thu, 23 Jun 2016 11:28:10 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:37818) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bG6Y0-0007tu-Iw; Thu, 23 Jun 2016 11:28:04 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3142 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bG6Xw-0002bn-N4; Thu, 23 Jun 2016 11:28:03 -0400 In-reply-to: (message from Tino Calancha on Thu, 23 Jun 2016 09:58:02 +0900) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:119976 Archived-At: > Cc: 23824@debbugs.gnu.org > From: Tino Calancha > Date: Thu, 23 Jun 2016 09:58:02 +0900 > > > I think we need first to establish what exactly is the semantic of > > this situation. You are comparing a buffer with the file that the > > buffer visits. The doc string of this function tries to say something > > about this situation: > > > > If the current buffer is visiting the file being compared against, it > > also will have its differences highlighted. Otherwise, the file is > > read in temporarily but the buffer is deleted. > > > > but I must confess that this is incomprehensible for me. So I think > > we should first establish what that means, or what the code is trying > > to do. > I understand what the doc means: if the current buffer (buf-a) is > visiting file-b, > then this func will perform a diff between buf-a and file-b. But then what is that "also" word doing in the doc string? > * So, if buf-a is modified, the command highlight you the differences > with file-b, so > let you decide if you want to save buf-a (overwritting file-b) or > not. It sounds useful. > * Current implementation doesn't match the doc string: even if buf-a is > visiting file-b and > modified, the func compare buf-a with buf-a, so that you never get > nothing highlight > in this case. I think there's more here than meets the eye. Did you ask yourself why the user is asked twice whether to save the same buffer to the same file in your scenario? Why does it do that? What does it have in mind? > >> + (with-current-buffer buf-new > >> + (insert-file-contents-literally file-b) > > ??? Why insert-file-contents-literally? That definitely sounds wrong. > > > > Thanks. > > We can use: (insert-file-contents file-b) > it doesn't matter. Oh, it matters a lot. insert-file-contents-literally will bypass any decoding and leave the CR-LF EOLs untranslated, something that you don't want to affect the comparison.