summaryrefslogtreecommitdiff
path: root/src/fns.c
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1993-03-10 05:13:24 +0000
committerRichard M. Stallman <rms@gnu.org>1993-03-10 05:13:24 +0000
commitf5313ed94c3c7bc4ca1a1c64e6e6d61f21f6604a (patch)
treeaf1fada4884d0d07daaeb7aa14ae747de2569a47 /src/fns.c
parent5cae0ec66cab39c4fe1655845707a412b433275a (diff)
downloademacs-f5313ed94c3c7bc4ca1a1c64e6e6d61f21f6604a.tar.gz
(Fy_or_n_p): Use query-replace-map.
Diffstat (limited to 'src/fns.c')
-rw-r--r--src/fns.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/src/fns.c b/src/fns.c
index 9165b98e830..21dd3cf6671 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -1093,13 +1093,15 @@ Also accepts Space to mean yes, or Delete to mean no.")
(prompt)
Lisp_Object prompt;
{
- register Lisp_Object obj;
- register int ans;
+ register Lisp_Object obj, key, def, answer_string, map;
+ register int answer;
Lisp_Object xprompt;
Lisp_Object args[2];
int ocech = cursor_in_echo_area;
struct gcpro gcpro1, gcpro2;
+ map = Fsymbol_value (intern ("query-replace-map"));
+
CHECK_STRING (prompt, 0);
xprompt = prompt;
GCPRO2 (prompt, xprompt);
@@ -1110,28 +1112,33 @@ Also accepts Space to mean yes, or Delete to mean no.")
cursor_in_echo_area = 1;
obj = read_char (0, 0, 0, Qnil, 0);
- if (XTYPE (obj) == Lisp_Int)
- ans = XINT (obj);
- else
- continue;
+ key = Fmake_vector (make_number (1), obj);
+ def = Flookup_key (map, key);
+ answer_string = Fsingle_key_description (obj);
cursor_in_echo_area = -1;
- message ("%s(y or n) %c", XSTRING (xprompt)->data, ans);
+ message ("%s(y or n) %s", XSTRING (xprompt)->data,
+ XSTRING (answer_string)->data);
cursor_in_echo_area = ocech;
- /* Accept a C-g or C-] (abort-recursive-edit) as quit requests. */
- if (ans == 7 || ans == '\035')
+
+ if (EQ (def, intern ("skip")))
+ {
+ answer = 0;
+ break;
+ }
+ else if (EQ (def, intern ("act")))
+ {
+ answer = 1;
+ break;
+ }
+ else if (EQ (def, intern ("quit")))
Vquit_flag = Qt;
+
QUIT;
/* If we don't clear this, then the next call to read_char will
return quit_char again, and we'll enter an infinite loop. */
Vquit_flag = Qnil;
- if (ans >= 0)
- ans = DOWNCASE (ans);
- if (ans == 'y' || ans == ' ')
- { ans = 'y'; break; }
- if (ans == 'n' || ans == 127)
- break;
Fding (Qnil);
Fdiscard_input ();
@@ -1143,7 +1150,7 @@ Also accepts Space to mean yes, or Delete to mean no.")
}
}
UNGCPRO;
- return (ans == 'y' ? Qt : Qnil);
+ return answer ? Qt : Qnil;
}
/* This is how C code calls `yes-or-no-p' and allows the user