changeset 47381:660a1a1b2f68

(diff-buffer-with-file): Simplify. Don't signal an error if buffer has no file. Call sit-for after `diff' returns.
author Richard M. Stallman <rms@gnu.org>
date Tue, 10 Sep 2002 16:48:52 +0000
parents 05670dbe9339
children 12f18e82e5e2
files lisp/files.el
diffstat 1 files changed, 14 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/files.el	Tue Sep 10 16:47:16 2002 +0000
+++ b/lisp/files.el	Tue Sep 10 16:48:52 2002 +0000
@@ -2996,23 +2996,21 @@
 
 (defun diff-buffer-with-file (&optional buffer)
   "View the differences between BUFFER and its associated file.
-This requires the external program \"diff\" to be in your `exec-path'."
+This requires the external program `diff' to be in your `exec-path'."
   (interactive "bBuffer: ")
-  (setq buffer (get-buffer (or buffer (current-buffer))))
-  (let ((buf-filename (buffer-file-name buffer)))
-    (unless buf-filename
-      (error "Buffer %s has no associated file" buffer))
-    (let ((tempfile (make-temp-file "buffer-content-")))
-      (unwind-protect
-	  (progn
-	    (with-current-buffer buffer
-	      (save-restriction
-		(widen)
-		(write-region (point-min) (point-max) tempfile nil 'nomessage)))
-	    (diff buf-filename tempfile nil t))
-	(when (file-exists-p tempfile)
-	  (delete-file tempfile)))
-      nil)))
+  (with-current-buffer (get-buffer (or buffer (current-buffer)))
+    (if (null buffer-file-name)
+	(message "Buffer %s has no associated file" (buffer-name))
+      (let ((tempfile (make-temp-file "buffer-content-")))
+	(unwind-protect
+	    (save-restriction
+	      (widen)
+	      (write-region (point-min) (point-max) tempfile nil 'nomessage)
+	      (diff buffer-file-name tempfile nil t)
+	      (sit-for 0))
+	  (when (file-exists-p tempfile)
+	    (delete-file tempfile)))
+	nil))))
 
 (defvar save-some-buffers-action-alist
   '((?\C-r