From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Only signal package.el warnings when needed Date: Mon, 14 Jan 2019 15:19:34 -0500 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1547497192 3297 195.159.176.226 (14 Jan 2019 20:19:52 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 14 Jan 2019 20:19:52 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 14 21:19:48 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gj8i2-0000h3-H5 for ged-emacs-devel@m.gmane.org; Mon, 14 Jan 2019 21:19:46 +0100 Original-Received: from localhost ([127.0.0.1]:44386 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gj8k9-0002IF-4s for ged-emacs-devel@m.gmane.org; Mon, 14 Jan 2019 15:21:57 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:57336) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gj8jG-0002Fl-7u for emacs-devel@gnu.org; Mon, 14 Jan 2019 15:21:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gj8i0-0001aa-EI for emacs-devel@gnu.org; Mon, 14 Jan 2019 15:19:45 -0500 Original-Received: from [195.159.176.226] (port=44466 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gj8hz-0001Zs-KR for emacs-devel@gnu.org; Mon, 14 Jan 2019 15:19:43 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1gj8fp-0005xI-Np for emacs-devel@gnu.org; Mon, 14 Jan 2019 21:17:29 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 94 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:Le5SOLJZrWzmyHAHaAWFjcRlnao= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:232345 Archived-At: > 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)