changeset 48178:8c6b3be30074

(Qset_buffer_major_mode_hook): New. (Fset_buffer_major_mode): Use it.
author Dave Love <fx@gnu.org>
date Wed, 06 Nov 2002 20:30:32 +0000
parents 3a459d1aa72c
children d9f249163ae0
files src/buffer.c
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/buffer.c	Wed Nov 06 09:25:58 2002 +0000
+++ b/src/buffer.c	Wed Nov 06 20:30:32 2002 +0000
@@ -178,6 +178,7 @@
 Lisp_Object Qmodification_hooks;
 Lisp_Object Qinsert_in_front_hooks;
 Lisp_Object Qinsert_behind_hooks;
+Lisp_Object Qset_buffer_major_mode_hook;
 
 static void alloc_buffer_text P_ ((struct buffer *, size_t));
 static void free_buffer_text P_ ((struct buffer *b));
@@ -1542,18 +1543,17 @@
 	function = current_buffer->major_mode;
     }
   
-  if (NILP (function) || EQ (function, Qfundamental_mode))
-    return Qnil;
-
   count = SPECPDL_INDEX ();
 
-  /* To select a nonfundamental mode,
-     select the buffer temporarily and then call the mode function. */
+  /* To select a nonfundamental mode, select the buffer temporarily
+     and then call the mode function.  Run the hook anyhow.  */
 
   record_unwind_protect (save_excursion_restore, save_excursion_save ());
 
   Fset_buffer (buffer);
-  call0 (function);
+  if (NILP (function) || EQ (function, Qfundamental_mode))
+    call0 (function);
+  Frun_hooks (1, &Qset_buffer_major_mode_hook);
 
   return unbind_to (count, Qnil);
 }
@@ -5128,6 +5128,8 @@
   staticpro (&Qbefore_change_functions);
   Qafter_change_functions = intern ("after-change-functions");
   staticpro (&Qafter_change_functions);
+  Qset_buffer_major_mode_hook = intern ("set-buffer-major-mode-hook");
+  staticpro (&Qset_buffer_major_mode_hook);
 
   Fput (Qprotected_field, Qerror_conditions,
 	Fcons (Qprotected_field, Fcons (Qerror, Qnil)));