all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tino Calancha <f92capac@gmail.com>
To: 23824@debbugs.gnu.org
Subject: bug#23824: 25.0.95; Prevent compare one buffer with itself
Date: Wed, 22 Jun 2016 19:12:13 +0900 (JST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1606221910180.6293@calancha-pc> (raw)


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







             reply	other threads:[~2016-06-22 10:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-22 10:12 Tino Calancha [this message]
2016-06-22 15:19 ` bug#23824: 25.0.95; Prevent compare one buffer with itself Eli Zaretskii
2016-06-23  0:58   ` Tino Calancha
2016-06-23 15:27     ` Eli Zaretskii
2016-06-24  5:07       ` Tino Calancha
2016-06-24 13:16         ` bug#23824: 25.0.95; Do not prompt twice to save a buffer Tino Calancha
2016-06-25 10:26           ` Eli Zaretskii
2016-06-26  1:59 ` bug#23824: (no subject) Tino Calancha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1606221910180.6293@calancha-pc \
    --to=f92capac@gmail.com \
    --cc=23824@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.