[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#23824: 25.0.95; Prevent compare one buffer with itself
From: |
Tino Calancha |
Subject: |
bug#23824: 25.0.95; Prevent compare one buffer with itself |
Date: |
Wed, 22 Jun 2016 19:12:13 +0900 (JST) |
User-agent: |
Alpine 2.20 (DEB 67 2015-01-07) |
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 <f92capac@gmail.com>
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
- bug#23824: 25.0.95; Prevent compare one buffer with itself,
Tino Calancha <=
bug#23824: (no subject), Tino Calancha, 2016/06/25