home *** CD-ROM | disk | FTP | other *** search
- ;;;; ask.jl -- Boolean prompting
- ;;; Copyright (C) 1993, 1994 John Harper <jsh@ukc.ac.uk>
-
- ;;; This file is part of Jade.
-
- ;;; Jade is free software; you can redistribute it and/or modify it
- ;;; under the terms of the GNU General Public License as published by
- ;;; the Free Software Foundation; either version 2, or (at your option)
- ;;; any later version.
-
- ;;; Jade is distributed in the hope that it will be useful, but
- ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
- ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ;;; GNU General Public License for more details.
-
- ;;; You should have received a copy of the GNU General Public License
- ;;; along with Jade; see the file COPYING. If not, write to
- ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
- (defun ask-yes-or-no (question-str)
- "(ask-yes-or-no QUESTION)
- Prompts the user for a yes or no answer to QUESTION, returns t for yes."
- (let*
- ((answer (prompt (concat question-str " (yes or no) "))))
- (string= "yes" answer)))
-
- (setq y-or-n-keymap (make-keylist))
- (bind-keys y-or-n-keymap
- "n" '(throw 'ask nil)
- "y" '(throw 'ask t))
-
- (defun ask-y-or-n (question-str)
- "(ask-y-or-n QUESTION)
- Prompts the user for a single keypress response, either `y' or `n' to the
- string QUESTION, returns t for `y'."
- (let*
- (answer
- (old-u-k-h unbound-key-hook)
- (old-k-p keymap-path)
- (title-string (concat question-str " (y or n)")))
- (setq unbound-key-hook
- (cons #'(lambda () (beep) (title title-string) t) nil))
- (setq keymap-path '(y-or-n-keymap))
- (title title-string)
- (setq answer (catch 'ask (recursive-edit)))
- (setq keymap-path old-k-p)
- (setq unbound-key-hook old-u-k-h)
- answer))
-
-