(unless (run-hook-with-args-until-failure 'kill-buffer-query-functions)
(error "Aborted"))
(when (and (buffer-modified-p) buffer-file-name)
- (if (yes-or-no-p "Buffer %s is modified; save it first? "
- (buffer-name))
+ (if (yes-or-no-p (format "Buffer %s is modified; save it first? "
+ (buffer-name)))
(save-buffer)
(unless (yes-or-no-p "Kill and replace the buffer without saving it? ")
(error "Aborted"))))
OP-TYPE specifies the file operation being performed (for message to user)."
(when (and large-file-warning-threshold size
(> size large-file-warning-threshold)
- (not (y-or-n-p "File %s is large (%dMB), really %s? "
- (file-name-nondirectory filename)
- (/ size 1048576) op-type)))
+ (not (y-or-n-p (format "File %s is large (%dMB), really %s? "
+ (file-name-nondirectory filename)
+ (/ size 1048576) op-type))))
(error "Aborted")))
(defun find-file-noselect (filename &optional nowarn rawfile wildcards)
(let ((buffer (and filename (find-buffer-visiting filename))))
(and buffer (not (eq buffer (current-buffer)))
(not no-query)
- (not (y-or-n-p "A buffer is visiting %s; proceed? "
- filename))
+ (not (y-or-n-p (format "A buffer is visiting %s; proceed? "
+ filename)))
(error "Aborted")))
(or (equal filename buffer-file-name)
(progn
(or buffer-file-name (buffer-name))))))
(and confirm
(file-exists-p filename)
- (or (y-or-n-p "File `%s' exists; overwrite? " filename)
+ (or (y-or-n-p (format "File `%s' exists; overwrite? " filename))
(error "Canceled")))
(set-visited-file-name filename (not confirm))))
(set-buffer-modified-p t)
(and targets
(or (eq delete-old-versions t) (eq delete-old-versions nil))
(or delete-old-versions
- (y-or-n-p "Delete excess backup versions of %s? "
- real-file-name))))
+ (y-or-n-p (format "Delete excess backup versions of %s? "
+ real-file-name)))))
(modes (file-modes buffer-file-name))
(context (file-selinux-context buffer-file-name)))
;; Actually write the back up file.
;; Signal an error if the user specified the name of an
;; existing directory.
(error "%s is a directory" filename)
- (unless (y-or-n-p "File `%s' exists; overwrite? "
- filename)
+ (unless (y-or-n-p (format "File `%s' exists; overwrite? "
+ filename))
(error "Canceled")))
;; Signal an error if the specified name refers to a
;; non-existing directory.
(or (verify-visited-file-modtime (current-buffer))
(not (file-exists-p buffer-file-name))
(yes-or-no-p
- "%s has changed since visited or saved. Save anyway? "
- (file-name-nondirectory buffer-file-name))
+ (format
+ "%s has changed since visited or saved. Save anyway? "
+ (file-name-nondirectory buffer-file-name)))
(error "Save not confirmed"))
(save-restriction
(widen)
(eq require-final-newline 'visit-save)
(and require-final-newline
(y-or-n-p
- "Buffer %s does not end in newline. Add one? "
- (buffer-name))))
+ (format "Buffer %s does not end in newline. Add one? "
+ (buffer-name)))))
(save-excursion
(goto-char (point-max))
(insert ?\n))))
(if (not (file-exists-p buffer-file-name))
(error "Directory %s write-protected" dir)
(if (yes-or-no-p
- "File %s is write-protected; try to save anyway? "
- (file-name-nondirectory
- buffer-file-name))
+ (format
+ "File %s is write-protected; try to save anyway? "
+ (file-name-nondirectory
+ buffer-file-name)))
(setq tempsetmodes t)
(error "Attempt to save to a file which you aren't allowed to write"))))))
(or buffer-backed-up
(progn
(if (or arg
(eq save-abbrevs 'silently)
- (y-or-n-p "Save abbrevs in %s? " abbrev-file-name))
+ (y-or-n-p (format "Save abbrevs in %s? " abbrev-file-name)))
(write-abbrev-file nil))
;; Don't keep bothering user if he says no.
(setq abbrevs-changed nil)
(list dir
(if (directory-files dir nil directory-files-no-dot-files-regexp)
(y-or-n-p
- "Directory `%s' is not empty, really %s? "
- dir (if trashing "trash" "delete"))
+ (format "Directory `%s' is not empty, really %s? "
+ dir (if trashing "trash" "delete")))
nil)
(null current-prefix-arg))))
;; If default-directory is a remote directory, make sure we find its
(dolist (regexp revert-without-query)
(when (string-match regexp file-name)
(throw 'found t)))))
- (yes-or-no-p "Revert buffer from file %s? "
- file-name))
+ (yes-or-no-p (format "Revert buffer from file %s? "
+ file-name)))
(run-hooks 'before-revert-hook)
;; If file was backed up but has changed since,
;; we should make another backup.
;; to emulate what `ls' did in that case.
(insert-directory-safely file switches)
(insert-directory-safely file-name switches))))
- (yes-or-no-p "Recover auto save file %s? " file-name))
+ (yes-or-no-p (format "Recover auto save file %s? " file-name)))
(switch-to-buffer (find-file-noselect file t))
(let ((inhibit-read-only t)
;; Keep the current buffer-file-coding-system.
(defun kill-buffer-ask (buffer)
"Kill BUFFER if confirmed."
- (when (yes-or-no-p
- "Buffer %s %s. Kill? " (buffer-name buffer)
- (if (buffer-modified-p buffer)
- "HAS BEEN EDITED" "is unmodified"))
+ (when (yes-or-no-p (format "Buffer %s %s. Kill? "
+ (buffer-name buffer)
+ (if (buffer-modified-p buffer)
+ "HAS BEEN EDITED" "is unmodified")))
(kill-buffer buffer)))
(defun kill-some-buffers (&optional list)
/* Anything that calls this function must protect from GC! */
-DEFUN ("yes-or-no-p", Fyes_or_no_p, Syes_or_no_p, 1, MANY, 0,
+DEFUN ("yes-or-no-p", Fyes_or_no_p, Syes_or_no_p, 1, 1, 0,
doc: /* Ask user a yes-or-no question. Return t if answer is yes.
-The string to display to ask the question is obtained by
-formatting the string PROMPT with arguments ARGS (see `format').
-The result should end in a space; `yes-or-no-p' adds
-\"(yes or no) \" to it.
+PROMPT is the string to display to ask the question. It should end in
+a space; `yes-or-no-p' adds \"(yes or no) \" to it.
The user must confirm the answer with RET, and can edit it until it
has been confirmed.
Under a windowing system a dialog box will be used if `last-nonmenu-event'
-is nil, and `use-dialog-box' is non-nil.
-usage: (yes-or-no-p PROMPT &rest ARGS) */)
- (int nargs, Lisp_Object *args)
+is nil, and `use-dialog-box' is non-nil. */)
+ (Lisp_Object prompt)
{
register Lisp_Object ans;
+ Lisp_Object args[2];
struct gcpro gcpro1;
- Lisp_Object prompt = Fformat (nargs, args);
+
+ CHECK_STRING (prompt);
#ifdef HAVE_MENUS
if (FRAME_WINDOW_P (SELECTED_FRAME ())
}
#endif /* HAVE_MENUS */
- prompt = concat2 (prompt, build_string ("(yes or no) "));
+ args[0] = prompt;
+ args[1] = build_string ("(yes or no) ");
+ prompt = Fconcat (2, args);
+
GCPRO1 (prompt);
while (1)