]> code.delx.au - gnu-emacs/blobdiff - src/macros.c
(Finsert_file_contents): Comment fix.
[gnu-emacs] / src / macros.c
index 5c37f0daa3da737b714ad767e8cca19390698ce2..4f5c77f6fbbdd8211c8ae0841311fc1c4ea146be 100644 (file)
@@ -1,5 +1,5 @@
 /* Keyboard macros.
-   Copyright (C) 1985, 1986, 1993 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1993, 2000, 2001 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -27,7 +27,7 @@ Boston, MA 02111-1307, USA.  */
 #include "window.h"
 #include "keyboard.h"
 
-Lisp_Object Qexecute_kbd_macro;
+Lisp_Object Qexecute_kbd_macro, Qkbd_macro_termination_hook;
 
 /* Kbd macro currently being executed (a string or vector).  */
 
@@ -61,7 +61,7 @@ The commands are recorded even as they are executed.\n\
 Use \\[end-kbd-macro] to finish recording and make the macro available.\n\
 Use \\[name-last-kbd-macro] to give it a permanent name.\n\
 Non-nil arg (prefix arg) means append to last macro defined;\n\
- This begins by re-executing that macro as if you typed it again.")
+this begins by re-executing that macro as if you typed it again.")
   (append)
      Lisp_Object append;
 {
@@ -183,17 +183,20 @@ store_kbd_macro_char (c)
           - current_kboard->kbd_macro_buffer)
          == current_kboard->kbd_macro_bufsize)
        {
-         register Lisp_Object *new;
+         int offset = (current_kboard->kbd_macro_ptr
+                       - current_kboard->kbd_macro_buffer);
          current_kboard->kbd_macro_bufsize *= 2;
-         new = (Lisp_Object *)xrealloc (current_kboard->kbd_macro_buffer,
-                                        (current_kboard->kbd_macro_bufsize
-                                         * sizeof (Lisp_Object)));
+         current_kboard->kbd_macro_buffer
+           = (Lisp_Object *)xrealloc (current_kboard->kbd_macro_buffer,
+                                      (current_kboard->kbd_macro_bufsize
+                                       * sizeof (Lisp_Object)));
          current_kboard->kbd_macro_ptr
-           += new - current_kboard->kbd_macro_buffer;
+           = current_kboard->kbd_macro_buffer + offset;
          current_kboard->kbd_macro_end
-           += new - current_kboard->kbd_macro_buffer;
-         current_kboard->kbd_macro_buffer = new;
+           = (current_kboard->kbd_macro_buffer
+              + current_kboard->kbd_macro_bufsize);
        }
+      
       *current_kboard->kbd_macro_ptr++ = c;
     }
 }
@@ -213,6 +216,7 @@ DEFUN ("cancel-kbd-macro-events", Fcancel_kbd_macro_events,
   ()
 {
   current_kboard->kbd_macro_ptr = current_kboard->kbd_macro_end;
+  return Qnil;
 }
 
 DEFUN ("store-kbd-macro-event", Fstore_kbd_macro_event,
@@ -269,6 +273,7 @@ pop_kbd_macro (info)
   tem = XCDR (info);
   executing_macro_index = XINT (XCAR (tem));
   real_this_command = XCDR (tem);
+  Frun_hooks (1, &Qkbd_macro_termination_hook);
   return Qnil;
 }
 
@@ -340,6 +345,8 @@ syms_of_macros ()
 {
   Qexecute_kbd_macro = intern ("execute-kbd-macro");
   staticpro (&Qexecute_kbd_macro);
+  Qkbd_macro_termination_hook = intern ("kbd-macro-termination-hook");
+  staticpro (&Qkbd_macro_termination_hook);
 
   defsubr (&Sstart_kbd_macro);
   defsubr (&Send_kbd_macro);