Subject: bug#23824: closed ()

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 26 Jun 2016 02:00:02 +0000

Your bug report

#23824: 25.0.95; Prevent compare one buffer with itself

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
23824: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=23824
GNU Bug Tracking System
Contact [email-masked] with problems

From: Tino Calancha <[email-masked]>
To: [email-masked]
Date: Sun, 26 Jun 2016 10:59:04 +0900 (JST)
List-Id: <debbugs-submit.debbugs.gnu.org>

Applied patch on master branch

Subject: 25.0.95; Prevent compare one buffer with itself
From: Tino Calancha <[email-masked]>
To: [email-masked]
Date: Wed, 22 Jun 2016 19:12:13 +0900 (JST)
List-Id: <debbugs-submit.debbugs.gnu.org>

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.

In GNU Emacs 25.0.95.2 (x86_64-pc-linux-gnu, GTK+ Version 3.20.6)
Repository revision: 829733104db073f8abd67765eae162e7360281fa

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

>From 47921b1f4898f9fad3acdaa15c2c70fa4b3f9061 Mon Sep 17 00:00:00 2001
From: Tino Calancha <[email-masked]>
Date: Wed, 22 Jun 2016 18:30:14 +0900
Subject: [PATCH] Prevent compare one buffer with itself

* lisp/hilit-chg.el (highlight-compare-with-file):
Use a new temporary buffer on sync with file-b; mark this
buffer as unmodified to prevent being prompt to save it (Bug#23824).
---
  lisp/hilit-chg.el | 14 +++++++++++---
  1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lisp/hilit-chg.el b/lisp/hilit-chg.el
index 8f042b6..89ca154 100644
--- a/lisp/hilit-chg.el
+++ b/lisp/hilit-chg.el
@@ -900,10 +900,18 @@ highlight-compare-with-file
    (let* ((buf-a (current-buffer))
  	 (file-a (buffer-file-name))
  	 (existing-buf (get-file-buffer file-b))
-	 (buf-b (or existing-buf
-		    (find-file-noselect file-b))))
+         (buf-b (cond ((eq buf-a existing-buf)
+                       (let ((buf-new (generate-new-buffer 
(generate-new-buffer-name
+                                                            (buffer-name 
buf-a)))))
+                         (with-current-buffer buf-new
+                           (insert-file-contents-literally file-b)
+                           (set-buffer-modified-p nil)) buf-new))
+                      (t
+                       (or existing-buf
+                           (find-file-noselect file-b))))))
      (highlight-markup-buffers buf-a file-a buf-b file-b (not 
existing-buf))
-    (unless existing-buf
+    (when (or (not existing-buf)
+              (eq buf-a existing-buf))
        (kill-buffer buf-b))
      ))

-- 
2.8.1