Mercurial > emacs
annotate lisp/map-ynp.el @ 4214:7c9552ef98fa
(Qmodification_hooks, Qinsert_in_front_hooks)
(Qinsert_behind_hooks): Moved to buffer.c.
(syms_of_textprop): Lisp vars setup deleted.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 21 Jul 1993 22:33:37 +0000 |
parents | cb593618786e |
children | 6a8d48a6ac10 |
rev | line source |
---|---|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
580
diff
changeset
|
1 ;;; map-ynp.el --- General-purpose boolean question-asker. |
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
580
diff
changeset
|
2 |
840
113281b361ec
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
811
diff
changeset
|
3 ;;; Copyright (C) 1991, 1992 Free Software Foundation, Inc. |
113281b361ec
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
811
diff
changeset
|
4 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
5 ;; Author: Roland McGrath <roland@gnu.ai.mit.edu> |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
6 ;; Keywords: lisp, extensions |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
7 |
304 | 8 ;;; This program is free software; you can redistribute it and/or modify |
9 ;;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
10 ;;; the Free Software Foundation; either version 2, or (at your option) |
304 | 11 ;;; any later version. |
12 ;;; | |
13 ;;; This program is distributed in the hope that it will be useful, | |
14 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 ;;; GNU General Public License for more details. | |
17 ;;; | |
18 ;;; A copy of the GNU General Public License can be obtained from this | |
19 ;;; program's author (send electronic mail to roland@ai.mit.edu) or from | |
20 ;;; the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA | |
21 ;;; 02139, USA. | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
22 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
23 ;;; Commentary: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
24 |
304 | 25 ;;; map-y-or-n-p is a general-purpose question-asking function. |
26 ;;; It asks a series of y/n questions (a la y-or-n-p), and decides to | |
27 ;;; applies an action to each element of a list based on the answer. | |
28 ;;; The nice thing is that you also get some other possible answers | |
29 ;;; to use, reminiscent of query-replace: ! to answer y to all remaining | |
30 ;;; questions; ESC or q to answer n to all remaining questions; . to answer | |
31 ;;; y once and then n for the remainder; and you can get help with C-h. | |
32 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
33 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
34 |
304 | 35 ;;;###autoload |
891 | 36 (defun map-y-or-n-p (prompter actor list &optional help action-alist) |
304 | 37 "Ask a series of boolean questions. |
891 | 38 Takes args PROMPTER ACTOR LIST, and optional args HELP and ACTION-ALIST. |
304 | 39 |
40 LIST is a list of objects, or a function of no arguments to return the next | |
41 object or nil. | |
42 | |
580 | 43 If PROMPTER is a string, the prompt is \(format PROMPTER OBJECT\). If not |
572 | 44 a string, PROMPTER is a function of one arg (an object from LIST), which |
45 returns a string to be used as the prompt for that object. If the return | |
46 value is not a string, it is eval'd to get the answer; it may be nil to | |
47 ignore the object, t to act on the object without asking the user, or a | |
48 form to do a more complex prompt. | |
49 | |
304 | 50 ACTOR is a function of one arg (an object from LIST), |
51 which gets called with each object that the user answers `yes' for. | |
52 | |
53 If HELP is given, it is a list (OBJECT OBJECTS ACTION), | |
54 where OBJECT is a string giving the singular noun for an elt of LIST; | |
55 OBJECTS is the plural noun for elts of LIST, and ACTION is a transitive | |
56 verb describing ACTOR. The default is \(\"object\" \"objects\" \"act on\"\). | |
57 | |
58 At the prompts, the user may enter y, Y, or SPC to act on that object; | |
59 n, N, or DEL to skip that object; ! to act on all following objects; | |
60 ESC or q to exit (skip all following objects); . (period) to act on the | |
61 current object and then exit; or \\[help-command] to get help. | |
62 | |
891 | 63 If ACTION-ALIST is given, it is an alist (KEY FUNCTION HELP) of extra keys |
64 that will be accepted. KEY is a character; FUNCTION is a function of one | |
65 arg (an object from LIST); HELP is a string. When the user hits KEY, | |
66 FUNCTION is called. If it returns non-nil, the object is considered | |
67 \"acted upon\", and the next object from LIST is processed. If it returns | |
68 nil, the prompt is repeated for the same object. | |
69 | |
2081
2b04be5e47e6
(map-y-or-n-p): Use query-replace-map.
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
70 This function uses `query-replace-map' to define the standard responses, |
2b04be5e47e6
(map-y-or-n-p): Use query-replace-map.
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
71 but not all of the responses which `query-replace' understands |
2b04be5e47e6
(map-y-or-n-p): Use query-replace-map.
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
72 are meaningful here. |
2b04be5e47e6
(map-y-or-n-p): Use query-replace-map.
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
73 |
304 | 74 Returns the number of actions taken." |
2081
2b04be5e47e6
(map-y-or-n-p): Use query-replace-map.
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
75 (let* ((user-keys (if action-alist |
1235
a9e3ec19b7d7
Use (function ...) around lambdas, so it works in v18.
Roland McGrath <roland@gnu.org>
parents:
911
diff
changeset
|
76 (concat (mapconcat (function |
a9e3ec19b7d7
Use (function ...) around lambdas, so it works in v18.
Roland McGrath <roland@gnu.org>
parents:
911
diff
changeset
|
77 (lambda (elt) |
a9e3ec19b7d7
Use (function ...) around lambdas, so it works in v18.
Roland McGrath <roland@gnu.org>
parents:
911
diff
changeset
|
78 (key-description |
a9e3ec19b7d7
Use (function ...) around lambdas, so it works in v18.
Roland McGrath <roland@gnu.org>
parents:
911
diff
changeset
|
79 (char-to-string (car elt))))) |
891 | 80 action-alist ", ") |
81 " ") | |
82 "")) | |
2442
f692546797f9
(map-y-or-n-p): Make bindings of user-defined keys be each a vector
Roland McGrath <roland@gnu.org>
parents:
2082
diff
changeset
|
83 ;; Make a map that defines each user key as a vector containing |
f692546797f9
(map-y-or-n-p): Make bindings of user-defined keys be each a vector
Roland McGrath <roland@gnu.org>
parents:
2082
diff
changeset
|
84 ;; its definition. |
2081
2b04be5e47e6
(map-y-or-n-p): Use query-replace-map.
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
85 (map (cons 'keymap |
2442
f692546797f9
(map-y-or-n-p): Make bindings of user-defined keys be each a vector
Roland McGrath <roland@gnu.org>
parents:
2082
diff
changeset
|
86 (append (mapcar (lambda (elt) |
f692546797f9
(map-y-or-n-p): Make bindings of user-defined keys be each a vector
Roland McGrath <roland@gnu.org>
parents:
2082
diff
changeset
|
87 (cons (car elt) (vector (nth 1 elt)))) |
2081
2b04be5e47e6
(map-y-or-n-p): Use query-replace-map.
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
88 action-alist) |
2b04be5e47e6
(map-y-or-n-p): Use query-replace-map.
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
89 query-replace-map))) |
474 | 90 (actions 0) |
3992
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
91 prompt char elt tail def delayed-switch-frame |
474 | 92 (next (if (or (symbolp list) |
93 (subrp list) | |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1616
diff
changeset
|
94 (byte-code-function-p list) |
474 | 95 (and (consp list) |
96 (eq (car list) 'lambda))) | |
97 (function (lambda () | |
98 (setq elt (funcall list)))) | |
99 (function (lambda () | |
100 (if list | |
101 (progn | |
102 (setq elt (car list) | |
103 list (cdr list)) | |
104 t) | |
105 nil)))))) | |
3992
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
106 (unwind-protect |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
107 (progn |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
108 (if (stringp prompter) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
109 (setq prompter (` (lambda (object) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
110 (format (, prompter) object))))) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
111 (while (funcall next) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
112 (setq prompt (funcall prompter elt)) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
113 (if (stringp prompt) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
114 (progn |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
115 (setq quit-flag nil) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
116 ;; Prompt the user about this object. |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
117 (let ((cursor-in-echo-area t)) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
118 (message "%s(y, n, !, ., q, %sor %s) " |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
119 prompt user-keys |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
120 (key-description (char-to-string help-char))) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
121 (setq char (read-event))) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
122 ;; Show the answer to the question. |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
123 (message "%s(y, n, !, ., q, %sor %s) %s" |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
124 prompt user-keys |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
125 (key-description (char-to-string help-char)) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
126 (single-key-description char)) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
127 (setq def (lookup-key map (vector char))) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
128 (cond ((eq def 'exit) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
129 (setq next (function (lambda () nil)))) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
130 ((eq def 'act) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
131 ;; Act on the object. |
319 | 132 (funcall actor elt) |
3992
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
133 (setq actions (1+ actions))) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
134 ((eq def 'skip) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
135 ;; Skip the object. |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
136 ) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
137 ((eq def 'act-and-exit) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
138 ;; Act on the object and then exit. |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
139 (funcall actor elt) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
140 (setq actions (1+ actions) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
141 next (function (lambda () nil)))) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
142 ((eq def 'quit) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
143 (setq quit-flag t) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
144 (setq next (` (lambda () |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
145 (setq next '(, next)) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
146 '(, elt))))) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
147 ((eq def 'automatic) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
148 ;; Act on this and all following objects. |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
149 (if (eval (funcall prompter elt)) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
150 (progn |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
151 (funcall actor elt) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
152 (setq actions (1+ actions)))) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
153 (while (funcall next) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
154 (if (eval (funcall prompter elt)) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
155 (progn |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
156 (funcall actor elt) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
157 (setq actions (1+ actions)))))) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
158 ((eq def 'help) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
159 (with-output-to-temp-buffer "*Help*" |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
160 (princ |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
161 (let ((object (if help (nth 0 help) "object")) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
162 (objects (if help (nth 1 help) "objects")) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
163 (action (if help (nth 2 help) "act on"))) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
164 (concat |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
165 (format "Type SPC or `y' to %s the current %s; |
2081
2b04be5e47e6
(map-y-or-n-p): Use query-replace-map.
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
166 DEL or `n' to skip the current %s; |
2b04be5e47e6
(map-y-or-n-p): Use query-replace-map.
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
167 ! to %s all remaining %s; |
2b04be5e47e6
(map-y-or-n-p): Use query-replace-map.
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
168 ESC or `q' to exit;\n" |
3992
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
169 action object object action objects) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
170 (mapconcat (function |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
171 (lambda (elt) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
172 (format "%c to %s" |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
173 (nth 0 elt) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
174 (nth 2 elt)))) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
175 action-alist |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
176 ";\n") |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
177 (if action-alist ";\n") |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
178 (format "or . (period) to %s \ |
2081
2b04be5e47e6
(map-y-or-n-p): Use query-replace-map.
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
179 the current %s and exit." |
3992
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
180 action object))))) |
2081
2b04be5e47e6
(map-y-or-n-p): Use query-replace-map.
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
181 |
3992
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
182 (setq next (` (lambda () |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
183 (setq next '(, next)) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
184 '(, elt))))) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
185 ((vectorp def) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
186 ;; A user-defined key. |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
187 (if (funcall (aref def 0) elt) ;Call its function. |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
188 ;; The function has eaten this object. |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
189 (setq actions (1+ actions)) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
190 ;; Regurgitated; try again. |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
191 (setq next (` (lambda () |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
192 (setq next '(, next)) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
193 '(, elt)))))) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
194 ((and (consp char) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
195 (eq (car char) 'switch-frame)) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
196 ;; switch-frame event. Put it off until we're done. |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
197 (setq delayed-switch-frame char) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
198 (setq next (` (lambda () |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
199 (setq next '(, next)) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
200 '(, elt))))) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
201 (t |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
202 ;; Random char. |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
203 (message "Type %s for help." |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
204 (key-description (char-to-string help-char))) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
205 (beep) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
206 (sit-for 1) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
207 (setq next (` (lambda () |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
208 (setq next '(, next)) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
209 '(, elt))))))) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
210 (if (eval prompt) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
211 (progn |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
212 (funcall actor elt) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
213 (setq actions (1+ actions))))))) |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
214 (if delayed-switch-frame |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
215 (setq unread-command-events |
cb593618786e
* map-ynp.el (map-y-or-n-p): If we get a switch-frame-event,
Jim Blandy <jimb@redhat.com>
parents:
2793
diff
changeset
|
216 (cons delayed-switch-frame unread-command-events)))) |
304 | 217 ;; Clear the last prompt from the minibuffer. |
218 (message "") | |
219 ;; Return the number of actions that were taken. | |
220 actions)) | |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
580
diff
changeset
|
221 |
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
580
diff
changeset
|
222 ;;; map-ynp.el ends here |