Function: edt-y-or-n-p

edt-y-or-n-p is a byte-compiled function defined in edt.el.gz.

Signature

(edt-y-or-n-p PROMPT &optional NOT-YES)

Documentation

Prompt for a y or n answer with positive default.

Like Emacs y-or-n-p, also accepts space as y and DEL as n. Argument PROMPT is the prompt string. Optional argument NOT-YES changes the default to negative.

Source Code

;; Defined in /usr/src/emacs/lisp/emulation/edt.el.gz
(defun edt-y-or-n-p (prompt &optional not-yes)
  "Prompt for a y or n answer with positive default.
Like Emacs `y-or-n-p', also accepts space as y and DEL as n.
Argument PROMPT is the prompt string.
Optional argument NOT-YES changes the default to negative."
  (message "%s[%s]" prompt (if not-yes "n" "y"))
  (let ((doit t))
    (while doit
      (setq doit nil)
      (let ((ans (read-char)))
	(cond ((or (= ans ?y) (= ans ?Y) (= ans ?\ ))
	       (setq edt-last-answer t))
	      ((or (= ans ?n) (= ans ?N) (= ans ?\C-?))
	       (setq edt-last-answer nil))
	      ((= ans ?\r) (setq edt-last-answer (not not-yes)))
	      (t
	       (setq doit t) (beep)
	       (message "Please answer y or n.  %s[%s]"
			prompt (if not-yes "n" "y")))))))
  edt-last-answer)