Function: call-last-kbd-macro

call-last-kbd-macro is an interactive function defined in macros.c.

Signature

(call-last-kbd-macro &optional PREFIX LOOPFUNC)

Documentation

Call the last keyboard macro that you defined with M-x start-kbd-macro (start-kbd-macro).

A prefix argument serves as a repeat count. Zero means repeat until error.

To make a macro permanent so you can call it even after defining others, use M-x name-last-kbd-macro (name-last-kbd-macro).

In Lisp, optional second arg LOOPFUNC may be a function that is called prior to each iteration of the macro. Iteration stops if LOOPFUNC returns nil.

Key Bindings

Source Code

// Defined in /usr/src/emacs/src/macros.c
{
  /* Don't interfere with recognition of the previous command
     from before this macro started.  */
  Vthis_command = KVAR (current_kboard, Vlast_command);
  /* C-x z after the macro should repeat the macro.  */
  Vreal_this_command = KVAR (current_kboard, Vlast_kbd_macro);

  if (! NILP (KVAR (current_kboard, defining_kbd_macro)))
    error ("Can't execute anonymous macro while defining one");
  else if (NILP (KVAR (current_kboard, Vlast_kbd_macro)))
    error ("No kbd macro has been defined");
  else
    Fexecute_kbd_macro (KVAR (current_kboard, Vlast_kbd_macro), prefix, loopfunc);

  /* command_loop_1 sets this to nil before it returns;
     get back the last command within the macro
     so that it can be last, again, after we return.  */
  Vthis_command = KVAR (current_kboard, Vlast_command);

  return Qnil;
}