changeset 2091:eedbad26e34c

(Fy_or_n_p): Use query-replace-map.
author Richard M. Stallman <rms@gnu.org>
date Wed, 10 Mar 1993 05:13:24 +0000
parents c7e1308a7184
children 7497fce1e426
files src/fns.c
diffstat 1 files changed, 23 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/fns.c	Wed Mar 10 05:12:42 1993 +0000
+++ b/src/fns.c	Wed Mar 10 05:13:24 1993 +0000
@@ -1093,13 +1093,15 @@
   (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 @@
       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 @@
 	}
     }
   UNGCPRO;
-  return (ans == 'y' ? Qt : Qnil);
+  return answer ? Qt : Qnil;
 }
 
 /* This is how C code calls `yes-or-no-p' and allows the user