Mercurial > emacs
changeset 47477:dec829d59f3c
(diff-buffer-with-file): Check whether associated file exists.
Display message for 1 second. Always return nil.
author | Markus Rost <rost@math.uni-bielefeld.de> |
---|---|
date | Fri, 13 Sep 2002 20:22:11 +0000 |
parents | 68e034e01f4c |
children | 62ec3a480410 |
files | lisp/files.el |
diffstat | 1 files changed, 18 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/files.el Fri Sep 13 19:45:36 2002 +0000 +++ b/lisp/files.el Fri Sep 13 20:22:11 2002 +0000 @@ -2999,18 +2999,24 @@ This requires the external program `diff' to be in your `exec-path'." (interactive "bBuffer: ") (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)))) + (if (and buffer-file-name + (file-exists-p buffer-file-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)))) + (message "Buffer %s has no associated file on disc" (buffer-name)) + ;; Display that message for 1 second so that user can read it + ;; in the minibuffer. + (sit-for 1))) + ;; return always nil, so that save-buffers-kill-emacs will not move + ;; over to the next unsaved buffer when calling `d'. + nil) (defvar save-some-buffers-action-alist '((?\C-r