From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.devel Subject: after-load-hook Date: Fri, 11 Sep 2009 22:53:31 +0200 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1252702454 5702 80.91.229.12 (11 Sep 2009 20:54:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 11 Sep 2009 20:54:14 +0000 (UTC) To: Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 11 22:54:07 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MmD88-0000Oq-SO for ged-emacs-devel@m.gmane.org; Fri, 11 Sep 2009 22:54:05 +0200 Original-Received: from localhost ([127.0.0.1]:43313 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MmD87-0006Qn-Vp for ged-emacs-devel@m.gmane.org; Fri, 11 Sep 2009 16:54:04 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MmD82-0006OH-14 for emacs-devel@gnu.org; Fri, 11 Sep 2009 16:53:58 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MmD7x-0006Hg-7f for emacs-devel@gnu.org; Fri, 11 Sep 2009 16:53:57 -0400 Original-Received: from [199.232.76.173] (port=52206 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MmD7w-0006HL-VM for emacs-devel@gnu.org; Fri, 11 Sep 2009 16:53:52 -0400 Original-Received: from mail-fx0-f226.google.com ([209.85.220.226]:57200) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MmD7w-0004Hm-EL for emacs-devel@gnu.org; Fri, 11 Sep 2009 16:53:52 -0400 Original-Received: by fxm26 with SMTP id 26so1109134fxm.42 for ; Fri, 11 Sep 2009 13:53:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:from:date:message-id :subject:to:content-type; bh=LTlSfD2JgAJglnZzyHXftbRbD+NCfc6SSBJhPO222uc=; b=we1hCvzIzDQ6qamzBXQ/e6aVxq4kRgoLZe9pww5YzbGNpy4Qip3zVSTjr0fEdldS3t bZRn6cKEoAyKWmmQbNhbuwJY3x8Ktfx1oZ83ePDYyr7CTSe9bCHUHSgzcYF0Fyf3h5UE 2h6vD1wG43tDcvCV95lvNOkFZEpGID6DzBJH4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=Dbqi138tj6bHpLhvLIsQCu+losxfzoxyCuqEfJ7MlwshqqwjWSz4wGSyFSJ+YiHg6v kpbIUyk+zdnWTY0iTIa2BD30npUH3L1CzHk+0xMzw0pWlZtyo4Vabwrr3iuXpDItgD74 iAKv2OarrPOiLlIDDan55ZqhPbN1+2PcFd7rY= Original-Received: by 10.239.138.6 with SMTP id n6mr316024hbn.77.1252702431122; Fri, 11 Sep 2009 13:53:51 -0700 (PDT) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:115202 Archived-At: 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 * lread.c (Qafter_load_hook): New constant. (Fload): Run hook. (syms_of_lread): Intern and staticpro Qafter_load_hook. 2009-09-11 Juanma Barranquero * 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))