aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorArtur Malabarba2015-09-07 23:51:42 +0100
committerArtur Malabarba2015-09-07 23:51:42 +0100
commitadd49b65a0bb50de447a95c1912232c79f28fdf9 (patch)
tree0271ff92d97dd40780b8e21ddf6336d6aac6192c /lisp
parentaff31904818e036e9f6a6c18342c624538be85d1 (diff)
downloademacs-add49b65a0bb50de447a95c1912232c79f28fdf9.tar.gz
emacs-add49b65a0bb50de447a95c1912232c79f28fdf9.zip
* lisp/emacs-lisp/package.el: Reduce autoloading before compiling
(package--autoloads-file-name) (package--activate-autoloads-and-load-path): New function. (package-activate-1): Delegate autoloading and load-path configuration to `package--activate-autoloads-and-load-path'. (package--compile): Before compilation, call `package--activate-autoloads-and-load-path' instead of `package-activate-1'.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emacs-lisp/package.el50
1 files changed, 32 insertions, 18 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 23247d78019..f6583bba487 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -639,6 +639,28 @@ specifying the minimum acceptable version."
639 (require 'finder-inf nil t) ; For `package--builtins'. 639 (require 'finder-inf nil t) ; For `package--builtins'.
640 (assq package package--builtins)))))) 640 (assq package package--builtins))))))
641 641
642(defun package--autoloads-file-name (pkg-desc)
643 "Return the absolute name of the autoloads file, sans extension.
644PKG-DESC is a `package-desc' object."
645 (expand-file-name
646 (format "%s-autoloads" (package-desc-name pkg-desc))
647 (package-desc-dir pkg-desc)))
648
649(defun package--activate-autoloads-and-load-path (pkg-desc)
650 "Load the autoloads file and add package dir to `load-path'.
651PKG-DESC is a `package-desc' object."
652 (let* ((old-lp load-path)
653 (pkg-dir (package-desc-dir pkg-desc))
654 (pkg-dir-dir (file-name-as-directory pkg-dir)))
655 (with-demoted-errors "Error loading autoloads: %s"
656 (load (package--autoloads-file-name pkg-desc) nil t))
657 (when (and (eq old-lp load-path)
658 (not (or (member pkg-dir load-path)
659 (member pkg-dir-dir load-path))))
660 ;; Old packages don't add themselves to the `load-path', so we have to
661 ;; do it ourselves.
662 (push pkg-dir load-path))))
663
642(defvar Info-directory-list) 664(defvar Info-directory-list)
643(declare-function info-initialize "info" ()) 665(declare-function info-initialize "info" ())
644 666
@@ -648,24 +670,14 @@ If RELOAD is non-nil, also `load' any files inside the package which
648correspond to previously loaded files (those returned by 670correspond to previously loaded files (those returned by
649`package--list-loaded-files')." 671`package--list-loaded-files')."
650 (let* ((name (package-desc-name pkg-desc)) 672 (let* ((name (package-desc-name pkg-desc))
651 (pkg-dir (package-desc-dir pkg-desc)) 673 (pkg-dir (package-desc-dir pkg-desc)))
652 (pkg-dir-dir (file-name-as-directory pkg-dir)))
653 (unless pkg-dir 674 (unless pkg-dir
654 (error "Internal error: unable to find directory for ā€˜%s’" 675 (error "Internal error: unable to find directory for ā€˜%s’"
655 (package-desc-full-name pkg-desc))) 676 (package-desc-full-name pkg-desc)))
656 ;; Add to load path, add autoloads, and activate the package. 677 (let* ((loaded-files-list (when reload
657 (let* ((old-lp load-path) 678 (package--list-loaded-files pkg-dir))))
658 (autoloads-file (expand-file-name 679 ;; Add to load path, add autoloads, and activate the package.
659 (format "%s-autoloads" name) pkg-dir)) 680 (package--activate-autoloads-and-load-path pkg-desc)
660 (loaded-files-list (and reload (package--list-loaded-files pkg-dir))))
661 (with-demoted-errors "Error in package-activate-1: %s"
662 (load autoloads-file nil t))
663 (when (and (eq old-lp load-path)
664 (not (or (member pkg-dir load-path)
665 (member pkg-dir-dir load-path))))
666 ;; Old packages don't add themselves to the `load-path', so we have to
667 ;; do it ourselves.
668 (push pkg-dir load-path))
669 ;; Call `load' on all files in `pkg-dir' already present in 681 ;; Call `load' on all files in `pkg-dir' already present in
670 ;; `load-history'. This is done so that macros in these files are updated 682 ;; `load-history'. This is done so that macros in these files are updated
671 ;; to their new definitions. If another package is being installed which 683 ;; to their new definitions. If another package is being installed which
@@ -674,7 +686,8 @@ correspond to previously loaded files (those returned by
674 (with-demoted-errors "Error in package-activate-1: %s" 686 (with-demoted-errors "Error in package-activate-1: %s"
675 (mapc (lambda (feature) (load feature nil t)) 687 (mapc (lambda (feature) (load feature nil t))
676 ;; Skip autoloads file since we already evaluated it above. 688 ;; Skip autoloads file since we already evaluated it above.
677 (remove (file-truename autoloads-file) loaded-files-list)))) 689 (remove (file-truename (package--autoloads-file-name pkg-desc))
690 loaded-files-list))))
678 ;; Add info node. 691 ;; Add info node.
679 (when (file-exists-p (expand-file-name "dir" pkg-dir)) 692 (when (file-exists-p (expand-file-name "dir" pkg-dir))
680 ;; FIXME: not the friendliest, but simple. 693 ;; FIXME: not the friendliest, but simple.
@@ -919,8 +932,9 @@ untar into a directory named DIR; otherwise, signal an error."
919(defun package--compile (pkg-desc) 932(defun package--compile (pkg-desc)
920 "Byte-compile installed package PKG-DESC." 933 "Byte-compile installed package PKG-DESC."
921 (let ((warning-minimum-level :error) 934 (let ((warning-minimum-level :error)
922 (save-silently inhibit-message)) 935 (save-silently inhibit-message)
923 (package-activate-1 pkg-desc) 936 (load-path load-path))
937 (package--activate-autoloads-and-load-path pkg-desc)
924 (byte-recompile-directory (package-desc-dir pkg-desc) 0 t))) 938 (byte-recompile-directory (package-desc-dir pkg-desc) 0 t)))
925 939
926;;;; Inferring package from current buffer 940;;;; Inferring package from current buffer