diff src/macros.c @ 280:7df0dd720c89 r21-0b38

Import from CVS: tag r21-0b38
author cvs
date Mon, 13 Aug 2007 10:32:22 +0200
parents c5d627a313b1
children 558f606b08ae
line wrap: on
line diff
--- a/src/macros.c	Mon Aug 13 10:31:30 2007 +0200
+++ b/src/macros.c	Mon Aug 13 10:32:22 2007 +0200
@@ -87,7 +87,7 @@
   return Qnil;
 }
 
-DEFUN ("end-kbd-macro", Fend_kbd_macro, 0, 1, "P", /*
+DEFUN ("end-kbd-macro", Fend_kbd_macro, 0, 2, "P", /*
 Finish defining a keyboard macro.
 The definition was started by \\[start-kbd-macro].
 The macro is now available for use via \\[call-last-kbd-macro],
@@ -97,16 +97,29 @@
 With numeric arg, repeat macro now that many times,
 counting the definition just completed as the first repetition.
 An argument of zero means repeat until error.
+
+If REMOVE-LAST is an integer, it means to not record the last number
+of events.  This is used internally and will likely be removed.
 */
-       (arg))
+       (arg, remove_last))
 {
   /* This function can GC */
   struct console *con = XCONSOLE (Vselected_console);
-  int repeat;
+  int repeat, kill;
 
   if (NILP (con->defining_kbd_macro))
     error ("Not defining kbd macro.");
 
+  /* #### Read the comment in modeline.el to see why this ugliness is
+     needed.  #### Try to avoid it, somehow!  */
+  if (!NILP (remove_last))
+    {
+      CHECK_NATNUM (remove_last);
+      kill = XINT (remove_last);
+    }
+  else
+    kill = 0;
+
   if (NILP (arg))
     repeat = -1;
   else
@@ -115,9 +128,12 @@
   if (!NILP (con->defining_kbd_macro))
     {
       int i;
-      int size = con->kbd_macro_end;
+      int size = con->kbd_macro_end - kill;
+
+      if (size < 0)
+	size = 0;
       con->last_kbd_macro = make_vector (size, Qnil);
-      for (i = 0; i < con->kbd_macro_end; i++)
+      for (i = 0; i < size; i++)
 	XVECTOR_DATA (con->last_kbd_macro) [i] =
 	  XVECTOR_DATA (con->kbd_macro_builder) [i];
       con->defining_kbd_macro = Qnil;