comparison 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
comparison
equal deleted inserted replaced
279:c20b2fb5bb0a 280:7df0dd720c89
85 con->defining_kbd_macro = Qt; 85 con->defining_kbd_macro = Qt;
86 86
87 return Qnil; 87 return Qnil;
88 } 88 }
89 89
90 DEFUN ("end-kbd-macro", Fend_kbd_macro, 0, 1, "P", /* 90 DEFUN ("end-kbd-macro", Fend_kbd_macro, 0, 2, "P", /*
91 Finish defining a keyboard macro. 91 Finish defining a keyboard macro.
92 The definition was started by \\[start-kbd-macro]. 92 The definition was started by \\[start-kbd-macro].
93 The macro is now available for use via \\[call-last-kbd-macro], 93 The macro is now available for use via \\[call-last-kbd-macro],
94 or it can be given a name with \\[name-last-kbd-macro] and then invoked 94 or it can be given a name with \\[name-last-kbd-macro] and then invoked
95 under that name. 95 under that name.
96 96
97 With numeric arg, repeat macro now that many times, 97 With numeric arg, repeat macro now that many times,
98 counting the definition just completed as the first repetition. 98 counting the definition just completed as the first repetition.
99 An argument of zero means repeat until error. 99 An argument of zero means repeat until error.
100 */ 100
101 (arg)) 101 If REMOVE-LAST is an integer, it means to not record the last number
102 of events. This is used internally and will likely be removed.
103 */
104 (arg, remove_last))
102 { 105 {
103 /* This function can GC */ 106 /* This function can GC */
104 struct console *con = XCONSOLE (Vselected_console); 107 struct console *con = XCONSOLE (Vselected_console);
105 int repeat; 108 int repeat, kill;
106 109
107 if (NILP (con->defining_kbd_macro)) 110 if (NILP (con->defining_kbd_macro))
108 error ("Not defining kbd macro."); 111 error ("Not defining kbd macro.");
109 112
113 /* #### Read the comment in modeline.el to see why this ugliness is
114 needed. #### Try to avoid it, somehow! */
115 if (!NILP (remove_last))
116 {
117 CHECK_NATNUM (remove_last);
118 kill = XINT (remove_last);
119 }
120 else
121 kill = 0;
122
110 if (NILP (arg)) 123 if (NILP (arg))
111 repeat = -1; 124 repeat = -1;
112 else 125 else
113 repeat = XINT (Fprefix_numeric_value (arg)); 126 repeat = XINT (Fprefix_numeric_value (arg));
114 127
115 if (!NILP (con->defining_kbd_macro)) 128 if (!NILP (con->defining_kbd_macro))
116 { 129 {
117 int i; 130 int i;
118 int size = con->kbd_macro_end; 131 int size = con->kbd_macro_end - kill;
132
133 if (size < 0)
134 size = 0;
119 con->last_kbd_macro = make_vector (size, Qnil); 135 con->last_kbd_macro = make_vector (size, Qnil);
120 for (i = 0; i < con->kbd_macro_end; i++) 136 for (i = 0; i < size; i++)
121 XVECTOR_DATA (con->last_kbd_macro) [i] = 137 XVECTOR_DATA (con->last_kbd_macro) [i] =
122 XVECTOR_DATA (con->kbd_macro_builder) [i]; 138 XVECTOR_DATA (con->kbd_macro_builder) [i];
123 con->defining_kbd_macro = Qnil; 139 con->defining_kbd_macro = Qnil;
124 MARK_MODELINE_CHANGED; 140 MARK_MODELINE_CHANGED;
125 message ("Keyboard macro defined"); 141 message ("Keyboard macro defined");