aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2019-01-22 17:54:29 -0500
committerStefan Monnier2019-01-22 17:54:29 -0500
commitdde33727b2ace3ce417d97475d074f0a82b7c2b8 (patch)
tree454946bd188a67e99e974b902417c6bb0575145e
parent7b31de4d107302ed91ce7519cd778b340a9880ee (diff)
downloademacs-dde33727b2ace3ce417d97475d074f0a82b7c2b8.tar.gz
emacs-dde33727b2ace3ce417d97475d074f0a82b7c2b8.zip
* lisp/emacs-lisp/package.el (package--alist): New
(package-activate-all): Use it so we only initialize the local part of package.el (this reduces the impact of bug#24467 and speeds up startup). (package-installed-p): Use it so it works even if package is not fully initialized. (package-delete): Use it so we only initialize the local part of package.el.
-rw-r--r--lisp/emacs-lisp/package.el37
1 files changed, 18 insertions, 19 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 9a7b54fa01a..025a1afbdbb 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -487,7 +487,7 @@ This is, approximately, the inverse of `version-to-list'.
487 str-list)))) 487 str-list))))
488 (if (equal "." (car str-list)) 488 (if (equal "." (car str-list))
489 (pop str-list)) 489 (pop str-list))
490 (apply 'concat (nreverse str-list))))) 490 (apply #'concat (nreverse str-list)))))
491 491
492(defun package-desc-full-name (pkg-desc) 492(defun package-desc-full-name (pkg-desc)
493 (format "%s-%s" 493 (format "%s-%s"
@@ -609,6 +609,12 @@ updates `package-alist'."
609 (when (file-directory-p pkg-dir) 609 (when (file-directory-p pkg-dir)
610 (package-load-descriptor pkg-dir)))))))) 610 (package-load-descriptor pkg-dir))))))))
611 611
612(defun package--alist ()
613 "Return `package-alist', after computing it if needed."
614 (or package-alist
615 (progn (package-load-all-descriptors)
616 package-alist)))
617
612(defun define-package (_name-string _version-string 618(defun define-package (_name-string _version-string
613 &optional _docstring _requirements 619 &optional _docstring _requirements
614 &rest _extra-properties) 620 &rest _extra-properties)
@@ -837,7 +843,7 @@ untar into a directory named DIR; otherwise, signal an error."
837 (tar-untar-buffer)) 843 (tar-untar-buffer))
838 844
839(defun package--alist-to-plist-args (alist) 845(defun package--alist-to-plist-args (alist)
840 (mapcar 'macroexp-quote 846 (mapcar #'macroexp-quote
841 (apply #'nconc 847 (apply #'nconc
842 (mapcar (lambda (pair) (list (car pair) (cdr pair))) alist)))) 848 (mapcar (lambda (pair) (list (car pair) (cdr pair))) alist))))
843(defun package-unpack (pkg-desc) 849(defun package-unpack (pkg-desc)
@@ -1492,9 +1498,7 @@ The variable `package-load-list' controls which packages to load."
1492 ;; any decoding). 1498 ;; any decoding).
1493 (let ((load-source-file-function nil)) 1499 (let ((load-source-file-function nil))
1494 (load package-quickstart-file nil 'nomessage)) 1500 (load package-quickstart-file nil 'nomessage))
1495 (unless package--initialized 1501 (dolist (elt (package--alist))
1496 (package-initialize t))
1497 (dolist (elt package-alist)
1498 (condition-case err 1502 (condition-case err
1499 (package-activate (car elt)) 1503 (package-activate (car elt))
1500 ;; Don't let failure of activation of a package arbitrarily stop 1504 ;; Don't let failure of activation of a package arbitrarily stop
@@ -1903,10 +1907,9 @@ If PACKAGE is a `package-desc' object, MIN-VERSION is ignored."
1903 ;; We used the quickstart: make it possible to use package-installed-p 1907 ;; We used the quickstart: make it possible to use package-installed-p
1904 ;; even before package is fully initialized. 1908 ;; even before package is fully initialized.
1905 (memq package package-activated-list)) 1909 (memq package package-activated-list))
1906 ((not package--initialized) (error "package.el is not yet initialized!"))
1907 (t 1910 (t
1908 (or 1911 (or
1909 (let ((pkg-descs (cdr (assq package package-alist)))) 1912 (let ((pkg-descs (cdr (assq package (package--alist)))))
1910 (and pkg-descs 1913 (and pkg-descs
1911 (version-list-<= min-version 1914 (version-list-<= min-version
1912 (package-desc-version (car pkg-descs))))) 1915 (package-desc-version (car pkg-descs)))))
@@ -2079,16 +2082,12 @@ If NOSAVE is non-nil, the package is not removed from
2079`package-selected-packages'." 2082`package-selected-packages'."
2080 (interactive 2083 (interactive
2081 (progn 2084 (progn
2082 ;; Initialize the package system to get the list of package
2083 ;; symbols for completion.
2084 (unless package--initialized
2085 (package-initialize t))
2086 (let* ((package-table 2085 (let* ((package-table
2087 (mapcar 2086 (mapcar
2088 (lambda (p) (cons (package-desc-full-name p) p)) 2087 (lambda (p) (cons (package-desc-full-name p) p))
2089 (delq nil 2088 (delq nil
2090 (mapcar (lambda (p) (unless (package-built-in-p p) p)) 2089 (mapcar (lambda (p) (unless (package-built-in-p p) p))
2091 (apply #'append (mapcar #'cdr package-alist)))))) 2090 (apply #'append (mapcar #'cdr (package--alist)))))))
2092 (package-name (completing-read "Delete package: " 2091 (package-name (completing-read "Delete package: "
2093 (mapcar #'car package-table) 2092 (mapcar #'car package-table)
2094 nil t))) 2093 nil t)))
@@ -2196,12 +2195,12 @@ will be deleted."
2196 ;; Load the package list if necessary (but don't activate them). 2195 ;; Load the package list if necessary (but don't activate them).
2197 (unless package--initialized 2196 (unless package--initialized
2198 (package-initialize t)) 2197 (package-initialize t))
2199 (let ((packages (append (mapcar 'car package-alist) 2198 (let ((packages (append (mapcar #'car package-alist)
2200 (mapcar 'car package-archive-contents) 2199 (mapcar #'car package-archive-contents)
2201 (mapcar 'car package--builtins)))) 2200 (mapcar #'car package--builtins))))
2202 (unless (memq guess packages) 2201 (unless (memq guess packages)
2203 (setq guess nil)) 2202 (setq guess nil))
2204 (setq packages (mapcar 'symbol-name packages)) 2203 (setq packages (mapcar #'symbol-name packages))
2205 (let ((val 2204 (let ((val
2206 (completing-read (if guess 2205 (completing-read (if guess
2207 (format "Describe package (default %s): " 2206 (format "Describe package (default %s): "
@@ -2507,7 +2506,7 @@ The description is read from the installed package files."
2507 :background "light grey" 2506 :background "light grey"
2508 :foreground "black") 2507 :foreground "black")
2509 'link))) 2508 'link)))
2510 (apply 'insert-text-button button-text 'face button-face 'follow-link t 2509 (apply #'insert-text-button button-text 'face button-face 'follow-link t
2511 props))) 2510 props)))
2512 2511
2513 2512
@@ -2588,7 +2587,7 @@ Letters do not insert themselves; instead, they are commands.
2588 ("Description" 0 nil)]) 2587 ("Description" 0 nil)])
2589 (setq tabulated-list-padding 2) 2588 (setq tabulated-list-padding 2)
2590 (setq tabulated-list-sort-key (cons "Status" nil)) 2589 (setq tabulated-list-sort-key (cons "Status" nil))
2591 (add-hook 'tabulated-list-revert-hook 'package-menu--refresh nil t) 2590 (add-hook 'tabulated-list-revert-hook #'package-menu--refresh nil t)
2592 (tabulated-list-init-header)) 2591 (tabulated-list-init-header))
2593 2592
2594(defmacro package--push (pkg-desc status listname) 2593(defmacro package--push (pkg-desc status listname)
@@ -2859,7 +2858,7 @@ shown."
2859 (package-menu--refresh packages keywords) 2858 (package-menu--refresh packages keywords)
2860 (setf (car (aref tabulated-list-format 0)) 2859 (setf (car (aref tabulated-list-format 0))
2861 (if keywords 2860 (if keywords
2862 (let ((filters (mapconcat 'identity keywords ","))) 2861 (let ((filters (mapconcat #'identity keywords ",")))
2863 (concat "Package[" filters "]")) 2862 (concat "Package[" filters "]"))
2864 "Package")) 2863 "Package"))
2865 (if keywords 2864 (if keywords