|
From: | Tino Calancha |
Subject: | bug#23824: 25.0.95; Prevent compare one buffer with itself |
Date: | Thu, 23 Jun 2016 09:58:02 +0900 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 |
On 06/23/2016 12:19 AM, Eli Zaretskii wrote:
I understand what the doc means: if the current buffer (buf-a) is visiting file-b,From: Tino Calancha <f92capac@gmail.com> Date: Wed, 22 Jun 2016 19:12:13 +0900 (JST) When the current buffer, buf-a, is visiting FILE-B, buf-b should be a temporary buffer on sync with FILE-B. ./emacs -r -Q -eval '(progn (with-temp-file "/tmp/foo" (insert "foo")) (find-file "/tmp/foo") (insert "bar"))' M-: (highlight-compare-with-file "/tmp/foo") RET n n ; Answer no to saving suggestions. ;; Current buffer content different than /tmp/foo but no face highlight-changes shown.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.
then this func will perform a diff between buf-a and file-b.* 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.
+ (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. At the end, what this func does is comparing buffers with ediff-diff-program so only the literal content would matter.
[Prev in Thread] | Current Thread | [Next in Thread] |