emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r114129: * src/keyboard.c (read_key_sequence_vs): Ne


From: Stefan Monnier
Subject: [Emacs-diffs] trunk r114129: * src/keyboard.c (read_key_sequence_vs): New function.
Date: Wed, 04 Sep 2013 20:32:26 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 114129
revision-id: address@hidden
parent: address@hidden
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Wed 2013-09-04 16:32:22 -0400
message:
  * src/keyboard.c (read_key_sequence_vs): New function.
  (Fread_key_sequence_vector, Fread_key_sequence): Use it to factor out
  common code.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/keyboard.c                 keyboard.c-20091113204419-o5vbwnq5f7feedwu-449
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-09-04 20:22:37 +0000
+++ b/src/ChangeLog     2013-09-04 20:32:22 +0000
@@ -1,5 +1,9 @@
 2013-09-04  Stefan Monnier  <address@hidden>
 
+       * keyboard.c (read_key_sequence_vs): New function.
+       (Fread_key_sequence_vector, Fread_key_sequence): Use it to factor out
+       common code.
+
        * callint.c (Fcall_interactively): Always return a vector for 'K'.
 
 2013-09-04  Paul Eggert  <address@hidden>

=== modified file 'src/keyboard.c'
--- a/src/keyboard.c    2013-08-27 18:47:55 +0000
+++ b/src/keyboard.c    2013-09-04 20:32:22 +0000
@@ -9712,6 +9712,66 @@
   return t;
 }
 
+static Lisp_Object
+read_key_sequence_vs (Lisp_Object prompt, Lisp_Object continue_echo,
+                     Lisp_Object dont_downcase_last,
+                     Lisp_Object can_return_switch_frame,
+                     Lisp_Object cmd_loop, bool allow_string)
+{
+  Lisp_Object keybuf[30];
+  register int i;
+  struct gcpro gcpro1;
+  ptrdiff_t count = SPECPDL_INDEX ();
+
+  if (!NILP (prompt))
+    CHECK_STRING (prompt);
+  QUIT;
+
+  specbind (Qinput_method_exit_on_first_char,
+           (NILP (cmd_loop) ? Qt : Qnil));
+  specbind (Qinput_method_use_echo_area,
+           (NILP (cmd_loop) ? Qt : Qnil));
+
+  memset (keybuf, 0, sizeof keybuf);
+  GCPRO1 (keybuf[0]);
+  gcpro1.nvars = (sizeof keybuf / sizeof (keybuf[0]));
+
+  if (NILP (continue_echo))
+    {
+      this_command_key_count = 0;
+      this_command_key_count_reset = 0;
+      this_single_command_key_start = 0;
+    }
+
+#ifdef HAVE_WINDOW_SYSTEM
+  if (display_hourglass_p)
+    cancel_hourglass ();
+#endif
+
+  i = read_key_sequence (keybuf, (sizeof keybuf / sizeof (keybuf[0])),
+                        prompt, ! NILP (dont_downcase_last),
+                        ! NILP (can_return_switch_frame), 0);
+
+#if 0  /* The following is fine for code reading a key sequence and
+         then proceeding with a lengthy computation, but it's not good
+         for code reading keys in a loop, like an input method.  */
+#ifdef HAVE_WINDOW_SYSTEM
+  if (display_hourglass_p)
+    start_hourglass ();
+#endif
+#endif
+
+  if (i == -1)
+    {
+      Vquit_flag = Qt;
+      QUIT;
+    }
+  UNGCPRO;
+  return unbind_to (count,
+                   ((allow_string ? make_event_array : Fvector)
+                    (i, keybuf)));
+}
+
 DEFUN ("read-key-sequence", Fread_key_sequence, Sread_key_sequence, 1, 5, 0,
        doc: /* Read a sequence of keystrokes and return as a string or vector.
 The sequence is sufficient to specify a non-prefix command in the
@@ -9761,56 +9821,8 @@
 will read just one key sequence.  */)
   (Lisp_Object prompt, Lisp_Object continue_echo, Lisp_Object 
dont_downcase_last, Lisp_Object can_return_switch_frame, Lisp_Object cmd_loop)
 {
-  Lisp_Object keybuf[30];
-  register int i;
-  struct gcpro gcpro1;
-  ptrdiff_t count = SPECPDL_INDEX ();
-
-  if (!NILP (prompt))
-    CHECK_STRING (prompt);
-  QUIT;
-
-  specbind (Qinput_method_exit_on_first_char,
-           (NILP (cmd_loop) ? Qt : Qnil));
-  specbind (Qinput_method_use_echo_area,
-           (NILP (cmd_loop) ? Qt : Qnil));
-
-  memset (keybuf, 0, sizeof keybuf);
-  GCPRO1 (keybuf[0]);
-  gcpro1.nvars = (sizeof keybuf / sizeof (keybuf[0]));
-
-  if (NILP (continue_echo))
-    {
-      this_command_key_count = 0;
-      this_command_key_count_reset = 0;
-      this_single_command_key_start = 0;
-    }
-
-#ifdef HAVE_WINDOW_SYSTEM
-  if (display_hourglass_p)
-    cancel_hourglass ();
-#endif
-
-  i = read_key_sequence (keybuf, (sizeof keybuf / sizeof (keybuf[0])),
-                        prompt, ! NILP (dont_downcase_last),
-                        ! NILP (can_return_switch_frame), 0);
-
-#if 0  /* The following is fine for code reading a key sequence and
-         then proceeding with a lengthy computation, but it's not good
-         for code reading keys in a loop, like an input method.  */
-#ifdef HAVE_WINDOW_SYSTEM
-  if (display_hourglass_p)
-    start_hourglass ();
-#endif
-#endif
-
-  if (i == -1)
-    {
-      Vquit_flag = Qt;
-      QUIT;
-    }
-  UNGCPRO;
-  return unbind_to (count, make_event_array (i, keybuf));
+  return read_key_sequence_vs (prompt, continue_echo, dont_downcase_last,
+                              can_return_switch_frame, cmd_loop, true);
 }
 
 DEFUN ("read-key-sequence-vector", Fread_key_sequence_vector,
@@ -9818,52 +9830,8 @@
        doc: /* Like `read-key-sequence' but always return a vector.  */)
   (Lisp_Object prompt, Lisp_Object continue_echo, Lisp_Object 
dont_downcase_last, Lisp_Object can_return_switch_frame, Lisp_Object cmd_loop)
 {
-  Lisp_Object keybuf[30];
-  register int i;
-  struct gcpro gcpro1;
-  ptrdiff_t count = SPECPDL_INDEX ();
-
-  if (!NILP (prompt))
-    CHECK_STRING (prompt);
-  QUIT;
-
-  specbind (Qinput_method_exit_on_first_char,
-           (NILP (cmd_loop) ? Qt : Qnil));
-  specbind (Qinput_method_use_echo_area,
-           (NILP (cmd_loop) ? Qt : Qnil));
-
-  memset (keybuf, 0, sizeof keybuf);
-  GCPRO1 (keybuf[0]);
-  gcpro1.nvars = (sizeof keybuf / sizeof (keybuf[0]));
-
-  if (NILP (continue_echo))
-    {
-      this_command_key_count = 0;
-      this_command_key_count_reset = 0;
-      this_single_command_key_start = 0;
-    }
-
-#ifdef HAVE_WINDOW_SYSTEM
-  if (display_hourglass_p)
-    cancel_hourglass ();
-#endif
-
-  i = read_key_sequence (keybuf, (sizeof keybuf / sizeof (keybuf[0])),
-                        prompt, ! NILP (dont_downcase_last),
-                        ! NILP (can_return_switch_frame), 0);
-
-#ifdef HAVE_WINDOW_SYSTEM
-  if (display_hourglass_p)
-    start_hourglass ();
-#endif
-
-  if (i == -1)
-    {
-      Vquit_flag = Qt;
-      QUIT;
-    }
-  UNGCPRO;
-  return unbind_to (count, Fvector (i, keybuf));
+  return read_key_sequence_vs (prompt, continue_echo, dont_downcase_last,
+                              can_return_switch_frame, cmd_loop, false);
 }
 
 /* Return true if input events are pending.  */


reply via email to

[Prev in Thread] Current Thread [Next in Thread]