Subject: Re: bug#12586: Acknowledgement (24.2.50; "q" in empty vc-diff buffer causes error)

From: Eric Hanchrow <[email-masked]>
Date: Sat, 6 Oct 2012 10:05:34 -0700

This patch seems to fix the problem.

diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 47800bd..c66c4db 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -1590,21 +1590,22 @@ Return t if the buffer had changes, nil otherwise."
     (let ((vc-disable-async-diff (not async)))
       (vc-call-backend (car vc-fileset) 'diff files rev1 rev2 buffer))
     (set-buffer buffer)
-    (if (and (zerop (buffer-size))
-             (not (get-buffer-process (current-buffer))))
+    (let ((pop (not
+
         ;; Treat this case specially so as not to pop the buffer.
-        (progn
-          (message "%s" (cdr messages))
-          nil)
-      (diff-mode)
+                (and (zerop (buffer-size))
+                     (not (get-buffer-process (current-buffer)))))))
+
       (set (make-local-variable 'diff-vc-backend) (car vc-fileset))
       (set (make-local-variable 'revert-buffer-function)
 	   `(lambda (ignore-auto noconfirm)
 	      (vc-diff-internal ,async ',vc-fileset ,rev1 ,rev2 ,verbose)))
-      ;; Make the *vc-diff* buffer read only, the diff-mode key
-      ;; bindings are nicer for read only buffers. pcl-cvs does the
-      ;; same thing.
-      (setq buffer-read-only t)
+
+      (let ((result (if (not pop)
+                        (progn
+                          (message "%s" (cdr messages))
+                          nil)
+
       ;; Display the buffer, but at the end because it can change point.
       (pop-to-buffer (current-buffer))
       ;; The diff process may finish early, so call `vc-diff-finish'
@@ -1616,6 +1617,14 @@ Return t if the buffer had changes, nil otherwise."
       ;; because we don't know that yet.
       t)))

+        ;; Make the *vc-diff* buffer read only, the diff-mode key
+        ;; bindings are nicer for read only buffers. pcl-cvs does the
+        ;; same thing.
+        (diff-mode)
+        (setq buffer-read-only t)
+
+        result))))
+
 (defun vc-read-revision (prompt &optional files backend default initial-input)
   (cond
    ((null files)