Commit 8b97da83 authored by Karl Heuer's avatar Karl Heuer
Browse files

(defining_kbd_macro): Delete; now part of perdisplay. All uses changed.

(kbd_macro_buffer, kbd_macro_ptr, kbd_macro_end): Likewise.
(kbd_macro_bufsize): Likewise.
(Fstart_kbd_macro): Initialize kbd_macro_buffer if not already done.
(init_macros): Delete initialization of defining_kbd_macro.
(syms_of_macros): Delete initialization of kbd_macro_buffer.
parent 834ec276
......@@ -27,22 +27,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
Lisp_Object Qexecute_kbd_macro;
int defining_kbd_macro;
/* The start of storage for the current keyboard macro, and its size. */
Lisp_Object *kbd_macro_buffer;
int kbd_macro_bufsize;
/* Where to store the next keystroke of the macro. */
Lisp_Object *kbd_macro_ptr;
/* The finalized section of the macro starts at kbd_macro_buffer and
ends before this. This is not the same as kbd_macro_pointer, because
we advance this to kbd_macro_pointer when a key's command is complete.
This way, the keystrokes for "end-kbd-macro" are not included in the
macro. */
Lisp_Object *kbd_macro_end;
Lisp_Object Vlast_kbd_macro;
Lisp_Object Vexecuting_macro;
......@@ -60,23 +44,29 @@ Non-nil arg (prefix arg) means append to last macro defined;\n\
(append)
Lisp_Object append;
{
if (defining_kbd_macro)
if (!NILP (current_perdisplay->defining_kbd_macro))
error ("Already defining kbd macro");
if (!current_perdisplay->kbd_macro_buffer)
{
current_perdisplay->kbd_macro_bufsize = 30;
current_perdisplay->kbd_macro_buffer
= (Lisp_Object *)malloc (30 * sizeof (Lisp_Object));
}
update_mode_lines++;
if (NILP (append))
{
kbd_macro_ptr = kbd_macro_buffer;
kbd_macro_end = kbd_macro_buffer;
current_perdisplay->kbd_macro_ptr = current_perdisplay->kbd_macro_buffer;
current_perdisplay->kbd_macro_end = current_perdisplay->kbd_macro_buffer;
message("Defining kbd macro...");
}
else
{
message("Appending to kbd macro...");
kbd_macro_ptr = kbd_macro_end;
current_perdisplay->kbd_macro_ptr = current_perdisplay->kbd_macro_end;
Fexecute_kbd_macro (Vlast_kbd_macro, make_number (1));
}
defining_kbd_macro++;
current_perdisplay->defining_kbd_macro = Qt;
return Qnil;
}
......@@ -94,7 +84,7 @@ An argument of zero means repeat until error.")
(arg)
Lisp_Object arg;
{
if (!defining_kbd_macro)
if (NILP (current_perdisplay->defining_kbd_macro))
error ("Not defining kbd macro.");
if (NILP (arg))
......@@ -102,12 +92,14 @@ An argument of zero means repeat until error.")
else
CHECK_NUMBER (arg, 0);
if (defining_kbd_macro)
if (!NILP (current_perdisplay->defining_kbd_macro))
{
defining_kbd_macro = 0;
current_perdisplay->defining_kbd_macro = Qnil;
update_mode_lines++;
Vlast_kbd_macro = make_event_array (kbd_macro_end - kbd_macro_buffer,
kbd_macro_buffer);
Vlast_kbd_macro
= make_event_array ((current_perdisplay->kbd_macro_end
- current_perdisplay->kbd_macro_buffer),
current_perdisplay->kbd_macro_buffer);
message("Keyboard macro defined");
}
......@@ -127,19 +119,24 @@ An argument of zero means repeat until error.")
store_kbd_macro_char (c)
Lisp_Object c;
{
if (defining_kbd_macro)
if (!NILP (current_perdisplay->defining_kbd_macro))
{
if (kbd_macro_ptr - kbd_macro_buffer == kbd_macro_bufsize)
if ((current_perdisplay->kbd_macro_ptr
- current_perdisplay->kbd_macro_buffer)
== current_perdisplay->kbd_macro_bufsize)
{
register Lisp_Object *new
= (Lisp_Object *) xrealloc (kbd_macro_buffer,
((kbd_macro_bufsize *= 2)
* sizeof (Lisp_Object)));
kbd_macro_ptr += new - kbd_macro_buffer;
kbd_macro_end += new - kbd_macro_buffer;
kbd_macro_buffer = new;
register Lisp_Object *new;
current_perdisplay->kbd_macro_bufsize *= 2;
new = (Lisp_Object *)xrealloc (current_perdisplay->kbd_macro_buffer,
(current_perdisplay->kbd_macro_bufsize
* sizeof (Lisp_Object)));
current_perdisplay->kbd_macro_ptr
+= new - current_perdisplay->kbd_macro_buffer;
current_perdisplay->kbd_macro_end
+= new - current_perdisplay->kbd_macro_buffer;
current_perdisplay->kbd_macro_buffer = new;
}
*kbd_macro_ptr++ = c;
*current_perdisplay->kbd_macro_ptr++ = c;
}
}
......@@ -148,7 +145,7 @@ store_kbd_macro_char (c)
finalize_kbd_macro_chars ()
{
kbd_macro_end = kbd_macro_ptr;
current_perdisplay->kbd_macro_end = current_perdisplay->kbd_macro_ptr;
}
DEFUN ("call-last-kbd-macro", Fcall_last_kbd_macro, Scall_last_kbd_macro,
......@@ -162,7 +159,7 @@ defining others, use \\[name-last-kbd-macro].")
(prefix)
Lisp_Object prefix;
{
if (defining_kbd_macro)
if (! NILP (current_perdisplay->defining_kbd_macro))
error ("Can't execute anonymous macro while defining one");
else if (NILP (Vlast_kbd_macro))
error ("No kbd macro has been defined");
......@@ -232,17 +229,11 @@ COUNT is a repeat count, or nil for once, or 0 for infinite loop.")
init_macros ()
{
Vlast_kbd_macro = Qnil;
defining_kbd_macro = 0;
Vexecuting_macro = Qnil;
}
syms_of_macros ()
{
kbd_macro_bufsize = 100;
kbd_macro_buffer = (Lisp_Object *) malloc (kbd_macro_bufsize
* sizeof (Lisp_Object));
Qexecute_kbd_macro = intern ("execute-kbd-macro");
staticpro (&Qexecute_kbd_macro);
......@@ -251,7 +242,7 @@ syms_of_macros ()
defsubr (&Scall_last_kbd_macro);
defsubr (&Sexecute_kbd_macro);
DEFVAR_BOOL ("defining-kbd-macro", &defining_kbd_macro,
DEFVAR_DISPLAY ("defining-kbd-macro", defining_kbd_macro,
"Non-nil while a keyboard macro is being defined. Don't set this!");
DEFVAR_LISP ("executing-macro", &Vexecuting_macro,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment