Previous: Passwords, Up: Minibuffer

8.8 Yes or No Prompts

An Emacs command may require you to answer a “yes or no” question during the course of its execution. Such queries come in two main varieties.

For the first type of “yes or no” query, the prompt ends with ‘(y or n)’. Such a query does not actually use the minibuffer; the prompt appears in the echo area, and you answer by typing either ‘y’ or ‘n’, which immediately delivers the response. For example, if you type C-x C-w (write-file) to save a buffer, and enter the name of an existing file, Emacs issues a prompt like this:

     File `foo.el' exists; overwrite? (y or n)

Because this query does not actually use the minibuffer, the usual minibuffer editing commands cannot be used. However, you can perform some window scrolling operations while the query is active: C-l recenters the selected window; M-v (or <PageDown> or <next>) scrolls forward; C-v (or <PageUp>, or <prior>) scrolls backward; C-M-v scrolls forward in the next window; and C-M-S-v scrolls backward in the next window. Typing C-g dismisses the query, and quits the command that issued it (see Quitting).

The second type of “yes or no” query is typically employed if giving the wrong answer would have serious consequences; it uses the minibuffer, and features a prompt ending with ‘(yes or no)’. For example, if you invoke C-x k (kill-buffer) on a file-visiting buffer with unsaved changes, Emacs activates the minibuffer with a prompt like this:

     Buffer foo.el modified; kill anyway? (yes or no)

To answer, you must type ‘yes’ or ‘no’ into the minibuffer, followed by <RET>. The minibuffer behaves as described in the previous sections; you can switch to another window with C-x o, use the history commands M-p and M-f, etc. Type C-g to quit the minibuffer and the querying command.