]> git.eshelyaron.com Git - emacs.git/commitdiff
(Vpost_gc_hook, Qpost_gc_hook): New variables.
authorGerd Moellmann <gerd@gnu.org>
Thu, 4 Oct 2001 09:17:15 +0000 (09:17 +0000)
committerGerd Moellmann <gerd@gnu.org>
Thu, 4 Oct 2001 09:17:15 +0000 (09:17 +0000)
(syms_of_alloc): DEFVAR_LISP post-gc-hook, initialize
Qpost_gc_hook.
(Fgarbage_collect): Run post-gc-hook.

src/alloc.c

index 00171011cccad67e6b13d8ee157dd2eaf682a61e..3d5f5f023f30b84e169eb0ebca4396f2334b0f17 100644 (file)
@@ -246,6 +246,10 @@ int ignore_warnings;
 
 Lisp_Object Qgc_cons_threshold, Qchar_table_extra_slots;
 
+/* Hook run after GC has finished.  */
+
+Lisp_Object Vpost_gc_hook, Qpost_gc_hook;
+
 static void mark_buffer P_ ((Lisp_Object));
 static void mark_kboards P_ ((void));
 static void gc_sweep P_ ((void));
@@ -4267,6 +4271,13 @@ Garbage collection happens automatically if you cons more than\n\
     }
 #endif
 
+  if (!NILP (Vpost_gc_hook))
+    {
+      int count = inhibit_garbage_collection ();
+      safe_run_hooks (Qpost_gc_hook);
+      unbind_to (count, Qnil);
+    }
+  
   return Flist (sizeof total / sizeof *total, total);
 }
 
@@ -5474,6 +5485,12 @@ which includes both saved text and other data.");
     "Non-nil means display messages at start and end of garbage collection.");
   garbage_collection_messages = 0;
 
+  DEFVAR_LISP ("post-gc-hook", &Vpost_gc_hook,
+    "Hook run after garbage collection has finished.");
+  Vpost_gc_hook = Qnil;
+  Qpost_gc_hook = intern ("post-gc-hook");
+  staticpro (&Qpost_gc_hook);
+
   /* We build this in advance because if we wait until we need it, we might
      not be able to allocate the memory to hold it.  */
   memory_signal_data