diff options
| author | Glenn Morris | 2011-11-10 20:46:03 -0500 |
|---|---|---|
| committer | Glenn Morris | 2011-11-10 20:46:03 -0500 |
| commit | 68cbc58be59373e805fa200db02e4022e20050f0 (patch) | |
| tree | 513ac91ee2d206f4456e2033b20af406146cfd60 | |
| parent | 9a4de110224cc0ea32a9c680db3f4355484236a6 (diff) | |
| download | emacs-68cbc58be59373e805fa200db02e4022e20050f0.tar.gz emacs-68cbc58be59373e805fa200db02e4022e20050f0.zip | |
eval-after-load fix for bug#10009
* lisp/subr.el (eval-after-load): If FILE is already loaded,
evaluate FORM before it gets wrapped in more stuff.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/subr.el | 43 |
2 files changed, 26 insertions, 22 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0b1572f9bce..6df54fb4527 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2011-11-11 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * subr.el (eval-after-load): If FILE is already loaded, | ||
| 4 | evaluate FORM before it gets wrapped in more stuff. (Bug#10009) | ||
| 5 | |||
| 1 | 2011-11-10 Glenn Morris <rgm@gnu.org> | 6 | 2011-11-10 Glenn Morris <rgm@gnu.org> |
| 2 | 7 | ||
| 3 | * vc/vc-svn.el (vc-svn-create-repo, vc-svn-modify-change-comment): | 8 | * vc/vc-svn.el (vc-svn-create-repo, vc-svn-modify-change-comment): |
diff --git a/lisp/subr.el b/lisp/subr.el index d5120826812..1cd6598eeb5 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -1797,30 +1797,29 @@ This function makes or adds to an entry on `after-load-alist'." | |||
| 1797 | (push elt after-load-alist)) | 1797 | (push elt after-load-alist)) |
| 1798 | ;; Make sure `form' is evalled in the current lexical/dynamic code. | 1798 | ;; Make sure `form' is evalled in the current lexical/dynamic code. |
| 1799 | (setq form `(funcall ',(eval `(lambda () ,form) lexical-binding))) | 1799 | (setq form `(funcall ',(eval `(lambda () ,form) lexical-binding))) |
| 1800 | (when (symbolp regexp-or-feature) | ||
| 1801 | ;; For features, the after-load-alist elements get run when `provide' is | ||
| 1802 | ;; called rather than at the end of the file. So add an indirection to | ||
| 1803 | ;; make sure that `form' is really run "after-load" in case the provide | ||
| 1804 | ;; call happens early. | ||
| 1805 | (setq form | ||
| 1806 | `(when load-file-name | ||
| 1807 | (let ((fun (make-symbol "eval-after-load-helper"))) | ||
| 1808 | (fset fun `(lambda (file) | ||
| 1809 | (if (not (equal file ',load-file-name)) | ||
| 1810 | nil | ||
| 1811 | (remove-hook 'after-load-functions ',fun) | ||
| 1812 | ,',form))) | ||
| 1813 | (add-hook 'after-load-functions fun))))) | ||
| 1814 | ;; Add FORM to the element unless it's already there. | ||
| 1815 | (unless (member form (cdr elt)) | ||
| 1816 | (nconc elt (purecopy (list form)))) | ||
| 1817 | |||
| 1818 | ;; Is there an already loaded file whose name (or `provide' name) | 1800 | ;; Is there an already loaded file whose name (or `provide' name) |
| 1819 | ;; matches FILE? | 1801 | ;; matches FILE? |
| 1820 | (if (if (stringp file) | 1802 | (prog1 (if (if (stringp file) |
| 1821 | (load-history-filename-element regexp-or-feature) | 1803 | (load-history-filename-element regexp-or-feature) |
| 1822 | (featurep file)) | 1804 | (featurep file)) |
| 1823 | (eval form)))) | 1805 | (eval form)) |
| 1806 | (when (symbolp regexp-or-feature) | ||
| 1807 | ;; For features, the after-load-alist elements get run when `provide' is | ||
| 1808 | ;; called rather than at the end of the file. So add an indirection to | ||
| 1809 | ;; make sure that `form' is really run "after-load" in case the provide | ||
| 1810 | ;; call happens early. | ||
| 1811 | (setq form | ||
| 1812 | `(when load-file-name | ||
| 1813 | (let ((fun (make-symbol "eval-after-load-helper"))) | ||
| 1814 | (fset fun `(lambda (file) | ||
| 1815 | (if (not (equal file ',load-file-name)) | ||
| 1816 | nil | ||
| 1817 | (remove-hook 'after-load-functions ',fun) | ||
| 1818 | ,',form))) | ||
| 1819 | (add-hook 'after-load-functions fun))))) | ||
| 1820 | ;; Add FORM to the element unless it's already there. | ||
| 1821 | (unless (member form (cdr elt)) | ||
| 1822 | (nconc elt (purecopy (list form))))))) | ||
| 1824 | 1823 | ||
| 1825 | (defvar after-load-functions nil | 1824 | (defvar after-load-functions nil |
| 1826 | "Special hook run after loading a file. | 1825 | "Special hook run after loading a file. |