[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Only signal package.el warnings when needed
From: |
Stefan Monnier |
Subject: |
Re: [PATCH] Only signal package.el warnings when needed |
Date: |
Mon, 14 Jan 2019 15:19:34 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
> I think we should install a patch like the one below to deal with this.
Actually, there are a few other places where we'd benefit from loading
the package-alist without initializing the whole package.el.
So maybe we should apply a patch like the one below instead (see
bug#31397).
Stefan
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 9a7b54fa01..503fc7e4cd 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -609,6 +609,12 @@ package-load-all-descriptors
(when (file-directory-p pkg-dir)
(package-load-descriptor pkg-dir))))))))
+(defun package--alist ()
+ "Return `package-alist', initializing it if needed."
+ (or package-alist
+ (progn (package-load-all-descriptors)
+ package-alist)))
+
(defun define-package (_name-string _version-string
&optional _docstring _requirements
&rest _extra-properties)
@@ -785,7 +791,7 @@ package-activate
"Activate the package named PACKAGE.
If FORCE is true, (re-)activate it if it's already activated.
Newer versions are always activated, regardless of FORCE."
- (let ((pkg-descs (cdr (assq package package-alist))))
+ (let ((pkg-descs (cdr (assq package (package--alist)))))
;; Check if PACKAGE is available in `package-alist'.
(while
(when pkg-descs
@@ -1492,9 +1498,7 @@ package-activate-all
;; any decoding).
(let ((load-source-file-function nil))
(load package-quickstart-file nil 'nomessage))
- (unless package--initialized
- (package-initialize t))
- (dolist (elt package-alist)
+ (dolist (elt (package--alist))
(condition-case err
(package-activate (car elt))
;; Don't let failure of activation of a package arbitrarily stop
@@ -1903,10 +1907,9 @@ package-installed-p
;; We used the quickstart: make it possible to use package-installed-p
;; even before package is fully initialized.
(memq package package-activated-list))
- ((not package--initialized) (error "package.el is not yet initialized!"))
(t
(or
- (let ((pkg-descs (cdr (assq package package-alist))))
+ (let ((pkg-descs (cdr (assq package (package--alist)))))
(and pkg-descs
(version-list-<= min-version
(package-desc-version (car pkg-descs)))))
@@ -2078,22 +2081,17 @@ package-delete
If NOSAVE is non-nil, the package is not removed from
`package-selected-packages'."
(interactive
- (progn
- ;; Initialize the package system to get the list of package
- ;; symbols for completion.
- (unless package--initialized
- (package-initialize t))
- (let* ((package-table
- (mapcar
- (lambda (p) (cons (package-desc-full-name p) p))
- (delq nil
- (mapcar (lambda (p) (unless (package-built-in-p p) p))
- (apply #'append (mapcar #'cdr package-alist))))))
- (package-name (completing-read "Delete package: "
- (mapcar #'car package-table)
- nil t)))
- (list (cdr (assoc package-name package-table))
- current-prefix-arg nil))))
+ (let* ((package-table
+ (mapcar
+ (lambda (p) (cons (package-desc-full-name p) p))
+ (delq nil
+ (mapcar (lambda (p) (unless (package-built-in-p p) p))
+ (apply #'append (mapcar #'cdr (package--alist)))))))
+ (package-name (completing-read "Delete package: "
+ (mapcar #'car package-table)
+ nil t)))
+ (list (cdr (assoc package-name package-table))
+ current-prefix-arg nil)))
(let ((dir (package-desc-dir pkg-desc))
(name (package-desc-name pkg-desc))
pkg-used-elsewhere-by)
- Re: [PATCH] Only signal package.el warnings when needed, (continued)
Re: [PATCH] Only signal package.el warnings when needed, Óscar Fuentes, 2019/01/14
Re: [PATCH] Only signal package.el warnings when needed, Stefan Monnier, 2019/01/14
- Re: [PATCH] Only signal package.el warnings when needed,
Stefan Monnier <=