(message "Warning: Change in load-path due to site-load will be \
lost after dumping")))
+;; Used by `kill-buffer', for instance.
+(load "emacs-lisp/rmc")
+
;; Make sure default-directory is unibyte when dumping. This is
;; because we cannot decode and encode it correctly (since the locale
;; environment is not, and should not be, set up). default-directory
(interactive)
(pop-to-buffer-same-window (get-scratch-buffer-create)))
+(defun kill-buffer--possibly-save (buffer)
+ (let ((response
+ (cadr
+ (read-multiple-choice
+ (format "Buffer %s modified; kill anyway?"
+ (buffer-name))
+ '((?y "yes" "kill buffer without saving")
+ (?n "no" "exit without doing anything")
+ (?s "save and then kill" "save the buffer and then kill it"))
+ nil nil (not use-short-answers)))))
+ (if (equal response "no")
+ nil
+ (unless (equal response "yes")
+ (with-current-buffer buffer
+ (save-buffer)))
+ t)))
+
\f
(provide 'simple)
/* Query if the buffer is still modified. */
if (INTERACTIVE && modified)
{
- AUTO_STRING (format, "Buffer %s modified; kill anyway? ");
- tem = do_yes_or_no_p (CALLN (Fformat, format, BVAR (b, name)));
- if (NILP (tem))
+ /* Ask whether to kill the buffer, and exit if the user says
+ "no". */
+ if (NILP (call1 (Qkill_buffer__possibly_save, buffer)))
return unbind_to (count, Qnil);
+ /* Recheck modified. */
+ modified = BUF_MODIFF (b) > BUF_SAVE_MODIFF (b);
}
/* Delete the autosave file, if requested. */
DEFSYM (Qautosaved, "autosaved");
+ DEFSYM (Qkill_buffer__possibly_save, "kill-buffer--possibly-save");
+
Fput (intern_c_string ("erase-buffer"), Qdisabled, Qt);
}