aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2009-09-15 03:39:40 +0000
committerStefan Monnier2009-09-15 03:39:40 +0000
commit838ff458025f7d59d5f9485363e9834f5a5dc063 (patch)
tree79cea934241448584016d30f0773c1a32391f6ea
parent8547eda3218b371d9f329f33f0d16203cfff918b (diff)
downloademacs-838ff458025f7d59d5f9485363e9834f5a5dc063.tar.gz
emacs-838ff458025f7d59d5f9485363e9834f5a5dc063.zip
(after-load-functions): New hook.
(do-after-load-evaluation): Run it. Use string-match-p to detect `obsolete' packages, rather than painfully extracting the relevant directory name.
-rw-r--r--etc/NEWS2
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/subr.el13
3 files changed, 18 insertions, 4 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 3339915e2ba..3db3f5342ad 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -210,6 +210,8 @@ functions and variables.
210 210
211* Lisp changes in Emacs 23.2 211* Lisp changes in Emacs 23.2
212 212
213** New hook `after-load-functions' run after loading an Elisp file.
214
213** You can control which binding is preferentially shown in menus and 215** You can control which binding is preferentially shown in menus and
214docstrings by adding a `:advertised-binding' property to the corresponding 216docstrings by adding a `:advertised-binding' property to the corresponding
215command's symbol. That property can hold a single binding or a list 217command's symbol. That property can hold a single binding or a list
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a40aa7a932f..5b52b49ef78 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12009-09-15 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * subr.el (after-load-functions): New hook.
4 (do-after-load-evaluation): Run it. Use string-match-p to detect
5 `obsolete' packages, rather than painfully extracting the relevant
6 directory name.
7
12009-09-15 Glenn Morris <rgm@gnu.org> 82009-09-15 Glenn Morris <rgm@gnu.org>
2 9
3 * apropos.el (apropos-documentation-check-doc-file): Avoid assignment to 10 * apropos.el (apropos-documentation-check-doc-file): Avoid assignment to
diff --git a/lisp/subr.el b/lisp/subr.el
index 85a74183a8d..560ab5695bd 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1670,6 +1670,11 @@ This function makes or adds to an entry on `after-load-alist'."
1670 (featurep file)) 1670 (featurep file))
1671 (eval form)))) 1671 (eval form))))
1672 1672
1673(defvar after-load-functions nil
1674 "Special hook run after loading a file.
1675Each function there is called with a single argument, the absolute
1676name of the file just loaded.")
1677
1673(defun do-after-load-evaluation (abs-file) 1678(defun do-after-load-evaluation (abs-file)
1674 "Evaluate all `eval-after-load' forms, if any, for ABS-FILE. 1679 "Evaluate all `eval-after-load' forms, if any, for ABS-FILE.
1675ABS-FILE, a string, should be the absolute true name of a file just loaded. 1680ABS-FILE, a string, should be the absolute true name of a file just loaded.
@@ -1682,15 +1687,15 @@ This function is called directly from the C code."
1682 (mapc #'eval (cdr a-l-element)))) 1687 (mapc #'eval (cdr a-l-element))))
1683 after-load-alist) 1688 after-load-alist)
1684 ;; Complain when the user uses obsolete files. 1689 ;; Complain when the user uses obsolete files.
1685 (when (equal "obsolete" 1690 (when (string-match-p "/obsolete/[^/]*\\'" abs-file)
1686 (file-name-nondirectory
1687 (directory-file-name (file-name-directory abs-file))))
1688 (run-with-timer 0 nil 1691 (run-with-timer 0 nil
1689 (lambda (file) 1692 (lambda (file)
1690 (message "Package %s is obsolete!" 1693 (message "Package %s is obsolete!"
1691 (substring file 0 1694 (substring file 0
1692 (string-match "\\.elc?\\>" file)))) 1695 (string-match "\\.elc?\\>" file))))
1693 (file-name-nondirectory abs-file)))) 1696 (file-name-nondirectory abs-file)))
1697 ;; Finally, run any other hook.
1698 (run-hook-with-args 'after-load-functions abs-file))
1694 1699
1695(defun eval-next-after-load (file) 1700(defun eval-next-after-load (file)
1696 "Read the following input sexp, and run it whenever FILE is loaded. 1701 "Read the following input sexp, and run it whenever FILE is loaded.