From: Markus Rost Date: Fri, 13 Sep 2002 20:22:29 +0000 (+0000) Subject: (diff-buffer-with-file): Check whether associated file exists. X-Git-Tag: ttn-vms-21-2-B4~13171 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=4e4e95198a1513ea23b45f2b747fcecaaf4fa06a;p=emacs.git (diff-buffer-with-file): Check whether associated file exists. Display message for 1 second. Always return nil. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c56b9536f90..ccda6c1344e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2002-09-13 Markus Rost + + * files.el (diff-buffer-with-file): Check whether associated file + exists. Display message for 1 second. Always return nil. + 2002-09-13 Stefan Monnier * derived.el (define-derived-mode): Properly ignore unknown args. @@ -81,8 +86,8 @@ 2002-09-11 Vinicius Jose Latorre - * ps-print.el: Adjust ps-print-color-p, ps-default-fg and ps-default-bg - setting. + * ps-print.el: Adjust ps-print-color-p, ps-default-fg and + ps-default-bg setting. (ps-print-version): New version number (6.5.7). (ps-mark-active-p): New fun. (ps-print-preprint-region): Adjust code. diff --git a/lisp/files.el b/lisp/files.el index 31d2b8762fa..020249dbf23 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2999,18 +2999,24 @@ After saving the buffer, this function runs `after-save-hook'." 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