From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: after-load-hook Date: Sat, 12 Sep 2009 00:16:16 -0400 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1252729001 28876 80.91.229.12 (12 Sep 2009 04:16:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 12 Sep 2009 04:16:41 +0000 (UTC) Cc: Emacs developers To: Juanma Barranquero Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Sep 12 06:16:34 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 1MmK2J-00018d-Ga for ged-emacs-devel@m.gmane.org; Sat, 12 Sep 2009 06:16:31 +0200 Original-Received: from localhost ([127.0.0.1]:53564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MmK2I-0006Aj-SZ for ged-emacs-devel@m.gmane.org; Sat, 12 Sep 2009 00:16:30 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MmK2D-0006Ae-Rn for emacs-devel@gnu.org; Sat, 12 Sep 2009 00:16:25 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MmK29-0006AI-Tg for emacs-devel@gnu.org; Sat, 12 Sep 2009 00:16:25 -0400 Original-Received: from [199.232.76.173] (port=47802 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MmK29-0006AE-Ou for emacs-devel@gnu.org; Sat, 12 Sep 2009 00:16:21 -0400 Original-Received: from [206.248.154.183] (port=52575 helo=ironport2-out.pppoe.ca) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MmK29-0002NN-7a for emacs-devel@gnu.org; Sat, 12 Sep 2009 00:16:21 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArMEAN29qkpFpZBe/2dsb2JhbACBU9oOhBgFh3I X-IronPort-AV: E=Sophos;i="4.44,374,1249272000"; d="scan'208";a="45598238" Original-Received: from 69-165-144-94.dsl.teksavvy.com (HELO ceviche.home) ([69.165.144.94]) by ironport2-out.pppoe.ca with ESMTP; 12 Sep 2009 00:14:44 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 1FA27B40D4; Sat, 12 Sep 2009 00:16:16 -0400 (EDT) In-Reply-To: (Juanma Barranquero's message of "Fri, 11 Sep 2009 22:53:31 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. 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:115213 Archived-At: > In the thread for bug#4287 I proposed adding an after-load-hook hook > to `load' (obviously :-). Funny, I just wrote the following patch earlier today. Stefan Index: lisp/subr.el =================================================================== RCS file: /sources/emacs/emacs/lisp/subr.el,v retrieving revision 1.652 diff -u -r1.652 subr.el --- lisp/subr.el 12 Sep 2009 03:55:50 -0000 1.652 +++ lisp/subr.el 12 Sep 2009 04:13:28 -0000 @@ -1670,6 +1674,11 @@ (featurep file)) (eval form)))) +(defvar after-load-functions nil + "Special hook run after loading a file. +Each function there is called with a single argument, the absolute +name of the file just loaded.") + (defun do-after-load-evaluation (abs-file) "Evaluate all `eval-after-load' forms, if any, for ABS-FILE. ABS-FILE, a string, should be the absolute true name of a file just loaded. @@ -1690,7 +1699,9 @@ (message "Package %s is obsolete!" (substring file 0 (string-match "\\.elc?\\>" file)))) - (file-name-nondirectory abs-file)))) + (file-name-nondirectory abs-file))) + ;; Finally, run any other hook. + (run-hook-with-args 'after-load-functions abs-file)) (defun eval-next-after-load (file) "Read the following input sexp, and run it whenever FILE is loaded.