summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChong Yidong <cyd@gnu.org>2012-03-12 11:03:16 +0800
committerChong Yidong <cyd@gnu.org>2012-03-12 11:03:16 +0800
commit292112ed3b196b6181010b0965a1df41d0cacf3a (patch)
treeb0544e40379a6f0e867d4bb85cfd742f183706bc
parent4098f8f73cf80eee975e9fc5c4b6fd3719e384ff (diff)
downloademacs-292112ed3b196b6181010b0965a1df41d0cacf3a.tar.gz
Load a package's generated autoloads file before byte compiling it.
* lisp/emacs-lisp/package.el (package-unpack, package-unpack-single): Load generated autoloads file before byte compiling. (package--make-autoloads-and-compile): New helper fun. Fixes: debbugs:10970
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/emacs-lisp/package.el23
2 files changed, 21 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4a3e895339a..9108455df44 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2012-03-12 Chong Yidong <cyd@gnu.org>
+
+ * emacs-lisp/package.el (package-unpack, package-unpack-single):
+ Load generated autoloads file before byte compiling (Bug#10970).
+ (package--make-autoloads-and-compile): New helper fun.
+
2012-03-12 Christopher Schmidt <christopher@ch.ristopher.com>
* ibuffer.el (ibuffer-redisplay): Remove another gratuitous error.
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index fd0eb029fc3..5b158eb994f 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -607,16 +607,25 @@ untar into a directory named DIR; otherwise, signal an error."
(error "Package does not untar cleanly into directory %s/" dir))))
(tar-untar-buffer))
-(defun package-unpack (name version)
- (let* ((dirname (concat (symbol-name name) "-" version))
+(defun package-unpack (package version)
+ (let* ((name (symbol-name package))
+ (dirname (concat name "-" version))
(pkg-dir (expand-file-name dirname package-user-dir)))
(make-directory package-user-dir t)
;; FIXME: should we delete PKG-DIR if it exists?
(let* ((default-directory (file-name-as-directory package-user-dir)))
(package-untar-buffer dirname)
- (package-generate-autoloads (symbol-name name) pkg-dir)
- (let ((load-path (cons pkg-dir load-path)))
- (byte-recompile-directory pkg-dir 0 t)))))
+ (package--make-autoloads-and-compile name pkg-dir))))
+
+(defun package--make-autoloads-and-compile (name pkg-dir)
+ "Generate autoloads and do byte-compilation for package named NAME.
+PKG-DIR is the name of the package directory."
+ (package-generate-autoloads name pkg-dir)
+ (let ((load-path (cons pkg-dir load-path)))
+ ;; We must load the autoloads file before byte compiling, in
+ ;; case there are magic cookies to set up non-trivial paths.
+ (load (expand-file-name (concat name "-autoloads") pkg-dir) nil t)
+ (byte-recompile-directory pkg-dir 0 t)))
(defun package--write-file-no-coding (file-name)
(let ((buffer-file-coding-system 'no-conversion))
@@ -656,9 +665,7 @@ untar into a directory named DIR; otherwise, signal an error."
nil
pkg-file
nil nil nil 'excl))
- (package-generate-autoloads file-name pkg-dir)
- (let ((load-path (cons pkg-dir load-path)))
- (byte-recompile-directory pkg-dir 0 t)))))
+ (package--make-autoloads-and-compile file-name pkg-dir))))
(defmacro package--with-work-buffer (location file &rest body)
"Run BODY in a buffer containing the contents of FILE at LOCATION.