unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juanma Barranquero <lekktu@gmail.com>
To: Emacs developers <emacs-devel@gnu.org>
Subject: after-load-hook
Date: Fri, 11 Sep 2009 22:53:31 +0200	[thread overview]
Message-ID: <f7ccd24b0909111353t31046c78l711dc48a5449bd54@mail.gmail.com> (raw)

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  <lekktu@gmail.com>

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

2009-09-11  Juanma Barranquero  <lekktu@gmail.com>

	* 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	other threads:[~2009-09-11 20:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-11 20:53 Juanma Barranquero [this message]
2009-09-12  4:16 ` after-load-hook Stefan Monnier
2009-09-12 11:19   ` after-load-hook Juanma Barranquero

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f7ccd24b0909111353t31046c78l711dc48a5449bd54@mail.gmail.com \
    --to=lekktu@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).