emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

after-load-hook


From: Juanma Barranquero
Subject: after-load-hook
Date: Fri, 11 Sep 2009 22:53:31 +0200

In the thread for bug#4287 I proposed adding an after-load-hook hook
to `load' (obviously :-).

Stefan said:

> We could replace the call from C to do-after-load-evaluation by
> Frun_hooks(Qafter-load-functions), either passing it the file name
> explicitly or making sure load-file-name is still set.

The following patch adds `after-load-hook'.

Comments:

 - It is not `after-load-functions', because it is a normal hook
(though `load-file-name' is set when the hook runs).
 - I haven't touched do-after-load-evaluation because I don't
understand what Stefan means by "replace" in this case.
 - No NEWS or info yet.

    Juanma



2009-09-11  Juanma Barranquero  <address@hidden>

        * lread.c (Qafter_load_hook): New constant.
        (Fload): Run hook.
        (syms_of_lread): Intern and staticpro Qafter_load_hook.

2009-09-11  Juanma Barranquero  <address@hidden>

        * subr.el (after-load-hook): New variable.
        * international/mule.el (load-with-code-conversion):
        Run `after-load-hook'.




Index: src/lread.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/lread.c,v
retrieving revision 1.412
diff -u -2 -r1.412 lread.c
--- src/lread.c 5 Sep 2009 00:45:08 -0000       1.412
+++ src/lread.c 11 Sep 2009 20:09:18 -0000
@@ -96,4 +96,5 @@
 Lisp_Object Qeval_buffer_list, Veval_buffer_list;
 Lisp_Object Qfile_truename, Qdo_after_load_evaluation; /* ACM 2006/5/16 */
+Lisp_Object Qafter_load_hook;

 /* Used instead of Qget_file_char while loading *.elc files compiled
@@ -1277,4 +1278,8 @@
                    0, Qnil, Qnil, Qnil, Qnil);
     }
+
+  /* Run hook while Qload_file_name is non-nil */
+  Frun_hooks (1, &Qafter_load_hook);
+
   unbind_to (count, Qnil);

@@ -4525,4 +4530,7 @@
   staticpro (&Qdo_after_load_evaluation) ;

+  Qafter_load_hook = intern ("after-load-hook");
+  staticpro (&Qafter_load_hook);
+
   staticpro (&dump_path);

Index: lisp/subr.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/subr.el,v
retrieving revision 1.650
diff -u -2 -r1.650 subr.el
--- lisp/subr.el        10 Sep 2009 18:19:06 -0000      1.650
+++ lisp/subr.el        11 Sep 2009 20:06:57 -0000
@@ -2277,4 +2277,9 @@
 mode.")

+(defvar after-load-hook nil
+  "Normal hook run by `load' after loading a file.
+When the hook runs, `load-file-name' contains the full name
+of the file just loaded.")
+
 ;; Avoid compiler warnings about this variable,
 ;; which has a special meaning on certain system types.
Index: lisp/international/mule.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/mule.el,v
retrieving revision 1.289
diff -u -2 -r1.289 mule.el
--- lisp/international/mule.el  3 Sep 2009 06:43:33 -0000       1.289
+++ lisp/international/mule.el  11 Sep 2009 20:06:57 -0000
@@ -354,4 +354,6 @@
        (let (kill-buffer-hook kill-buffer-query-functions)
          (kill-buffer buffer)))
+
+      (run-hooks 'after-load-hook)
       (unless purify-flag
        (do-after-load-evaluation fullname))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]