2999 |
This requires the external program `diff' to be in your `exec-path'." |
This requires the external program `diff' to be in your `exec-path'." |
3000 |
(interactive "bBuffer: ") |
(interactive "bBuffer: ") |
3001 |
(with-current-buffer (get-buffer (or buffer (current-buffer))) |
(with-current-buffer (get-buffer (or buffer (current-buffer))) |
3002 |
(if (null buffer-file-name) |
(if (and buffer-file-name |
3003 |
(message "Buffer %s has no associated file" (buffer-name)) |
(file-exists-p buffer-file-name)) |
3004 |
(let ((tempfile (make-temp-file "buffer-content-"))) |
(let ((tempfile (make-temp-file "buffer-content-"))) |
3005 |
(unwind-protect |
(unwind-protect |
3006 |
(save-restriction |
(save-restriction |
3007 |
(widen) |
(widen) |
3008 |
(write-region (point-min) (point-max) tempfile nil 'nomessage) |
(write-region (point-min) (point-max) tempfile nil 'nomessage) |
3009 |
(diff buffer-file-name tempfile nil t) |
(diff buffer-file-name tempfile nil t) |
3010 |
(sit-for 0)) |
(sit-for 0)) |
3011 |
(when (file-exists-p tempfile) |
(when (file-exists-p tempfile) |
3012 |
(delete-file tempfile))) |
(delete-file tempfile)))) |
3013 |
nil)))) |
(message "Buffer %s has no associated file on disc" (buffer-name)) |
3014 |
|
;; Display that message for 1 second so that user can read it |
3015 |
|
;; in the minibuffer. |
3016 |
|
(sit-for 1))) |
3017 |
|
;; return always nil, so that save-buffers-kill-emacs will not move |
3018 |
|
;; over to the next unsaved buffer when calling `d'. |
3019 |
|
nil) |
3020 |
|
|
3021 |
(defvar save-some-buffers-action-alist |
(defvar save-some-buffers-action-alist |
3022 |
'((?\C-r |
'((?\C-r |