unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Subject: Re: [PATCH] Only signal package.el warnings when needed
Date: Mon, 14 Jan 2019 15:19:34 -0500	[thread overview]
Message-ID: <jwvfttvgfmz.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: jwvsgxvghnz.fsf-monnier+emacs@gnu.org

> 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)




      reply	other threads:[~2019-01-14 20:19 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-14  4:17 [PATCH] Only signal package.el warnings when needed Radon Rosborough
2019-01-14 15:48 ` Eli Zaretskii
2019-01-14 16:10   ` Robert Pluim
2019-01-14 16:39     ` Eli Zaretskii
2019-01-14 16:48       ` Robert Pluim
2019-01-14 20:14     ` Stefan Monnier
2019-01-14 21:46     ` Radon Rosborough
2019-01-14 21:46   ` Radon Rosborough
2019-01-15 17:18     ` Eli Zaretskii
2019-01-15 18:43       ` Radon Rosborough
2019-01-15 19:26         ` Eli Zaretskii
2019-01-21 22:45           ` Radon Rosborough
2019-01-22 17:29             ` Eli Zaretskii
2019-01-23  4:06               ` Radon Rosborough
2019-01-23 15:34                 ` Eli Zaretskii
2019-01-23 16:00                   ` Stefan Monnier
2019-01-23 17:28                   ` Radon Rosborough
2019-01-14 22:13   ` Óscar Fuentes
2019-01-14 22:59     ` Clément Pit-Claudel
2019-01-15 10:39       ` João Távora
2019-01-15 17:15         ` Eli Zaretskii
2019-01-15 17:24           ` João Távora
2019-01-14 19:55 ` Stefan Monnier
2019-01-14 20:19   ` Stefan Monnier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvfttvgfmz.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).