aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2002-09-10 16:48:52 +0000
committerRichard M. Stallman2002-09-10 16:48:52 +0000
commit0b9e474953bbf5b9168821b7f86cf2a349aae511 (patch)
tree4c0c91a7be3be5e3bfc6bbe8b0fefc5cd01b4c84
parenta5bce90d94822212dac326081badb4bb2474efba (diff)
downloademacs-0b9e474953bbf5b9168821b7f86cf2a349aae511.tar.gz
emacs-0b9e474953bbf5b9168821b7f86cf2a349aae511.zip
(diff-buffer-with-file): Simplify.
Don't signal an error if buffer has no file. Call sit-for after `diff' returns.
-rw-r--r--lisp/files.el30
1 files changed, 14 insertions, 16 deletions
diff --git a/lisp/files.el b/lisp/files.el
index f86afe8d5d2..31d2b8762fa 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2996,23 +2996,21 @@ After saving the buffer, this function runs `after-save-hook'."
2996 2996
2997(defun diff-buffer-with-file (&optional buffer) 2997(defun diff-buffer-with-file (&optional buffer)
2998 "View the differences between BUFFER and its associated file. 2998 "View the differences between BUFFER and its associated file.
2999This requires the external program \"diff\" to be in your `exec-path'." 2999This requires the external program `diff' to be in your `exec-path'."
3000 (interactive "bBuffer: ") 3000 (interactive "bBuffer: ")
3001 (setq buffer (get-buffer (or buffer (current-buffer)))) 3001 (with-current-buffer (get-buffer (or buffer (current-buffer)))
3002 (let ((buf-filename (buffer-file-name buffer))) 3002 (if (null buffer-file-name)
3003 (unless buf-filename 3003 (message "Buffer %s has no associated file" (buffer-name))
3004 (error "Buffer %s has no associated file" buffer)) 3004 (let ((tempfile (make-temp-file "buffer-content-")))
3005 (let ((tempfile (make-temp-file "buffer-content-"))) 3005 (unwind-protect
3006 (unwind-protect 3006 (save-restriction
3007 (progn 3007 (widen)
3008 (with-current-buffer buffer 3008 (write-region (point-min) (point-max) tempfile nil 'nomessage)
3009 (save-restriction 3009 (diff buffer-file-name tempfile nil t)
3010 (widen) 3010 (sit-for 0))
3011 (write-region (point-min) (point-max) tempfile nil 'nomessage))) 3011 (when (file-exists-p tempfile)
3012 (diff buf-filename tempfile nil t)) 3012 (delete-file tempfile)))
3013 (when (file-exists-p tempfile) 3013 nil))))
3014 (delete-file tempfile)))
3015 nil)))
3016 3014
3017(defvar save-some-buffers-action-alist 3015(defvar save-some-buffers-action-alist
3018 '((?\C-r 3016 '((?\C-r