Don't require cl, fortran.
[bpt/emacs.git] / lisp / map-ynp.el
index 5ca5a7e..be664e0 100644 (file)
@@ -2,7 +2,8 @@
 
 ;; Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
 
-;; Author: Roland McGrath <roland@gnu.ai.mit.edu>
+;; Author: Roland McGrath <roland@gnu.org>
+;; Maintainer: FSF
 ;; Keywords: lisp, extensions
 
 ;; This file is part of GNU Emacs.
@@ -26,7 +27,7 @@
 
 ;; map-y-or-n-p is a general-purpose question-asking function.
 ;; It asks a series of y/n questions (a la y-or-n-p), and decides to
-;; applies an action to each element of a list based on the answer.
+;; apply an action to each element of a list based on the answer.
 ;; The nice thing is that you also get some other possible answers
 ;; to use, reminiscent of query-replace: ! to answer y to all remaining
 ;; questions; ESC or q to answer n to all remaining questions; . to answer
@@ -34,7 +35,6 @@
 
 ;;; Code:
 
-;;;###autoload
 (defun map-y-or-n-p (prompter actor list &optional help action-alist
                              no-cursor-in-echo-area)
   "Ask a series of boolean questions.
@@ -79,6 +79,8 @@ are meaningful here.
 Returns the number of actions taken."
   (let* ((actions 0)
         user-keys mouse-event map prompt char elt tail def
+        ;; Non-nil means we should use mouse menus to ask.
+        use-menus
         delayed-switch-frame
         (next (if (or (and list (symbolp list))
                       (subrp list)
@@ -108,6 +110,7 @@ Returns the number of actions taken."
                                      (cons (capitalize (nth 2 elt))
                                            (vector (nth 1 elt))))
                                    action-alist))))
+               use-menus t
                mouse-event last-nonmenu-event))                               
       (setq user-keys (if action-alist
                          (concat (mapconcat (function
@@ -134,8 +137,8 @@ Returns the number of actions taken."
            (cond ((stringp prompt)
                   ;; Prompt the user about this object.
                   (setq quit-flag nil)
-                  (if mouse-event
-                      (setq def (or (x-popup-dialog mouse-event
+                  (if use-menus
+                      (setq def (or (x-popup-dialog (or mouse-event use-menus)
                                                     (cons prompt map))
                                     'quit))
                     ;; Prompt in the echo area.
@@ -144,7 +147,13 @@ Returns the number of actions taken."
                       (message "%s(y, n, !, ., q, %sor %s) "
                                prompt user-keys
                                (key-description (vector help-char)))
-                      (setq char (read-event))
+                      (if minibuffer-auto-raise
+                          (raise-frame (window-frame (minibuffer-window))))
+                      (while (progn
+                               (setq char (read-event))
+                               ;; If we get -1, from end of keyboard
+                               ;; macro, try again.
+                                (equal char -1)))
                       ;; Show the answer to the question.
                       (message "%s(y, n, !, ., q, %sor %s) %s"
                                prompt user-keys
@@ -190,9 +199,11 @@ Returns the number of actions taken."
                               (concat
                                (format "Type SPC or `y' to %s the current %s;
 DEL or `n' to skip the current %s;
+RET or `q' to exit (skip all remaining %s);
 ! to %s all remaining %s;
 ESC or `q' to exit;\n"
-                                       action object object action objects)
+                                       action object object objects action
+                                       objects)
                                (mapconcat (function
                                            (lambda (elt)
                                              (format "%c to %s"