From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: George Plymale II Newsgroups: gmane.emacs.devel Subject: Re: Loading a package applies automatically to future sessions? Date: Tue, 30 Jan 2018 17:56:34 -0500 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1517353080 13214 195.159.176.226 (30 Jan 2018 22:58:00 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 30 Jan 2018 22:58:00 +0000 (UTC) Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: George Plymale II Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jan 30 23:57:56 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egeqJ-0001db-4S for ged-emacs-devel@m.gmane.org; Tue, 30 Jan 2018 23:57:31 +0100 Original-Received: from localhost ([::1]:42148 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1egesJ-00080h-Rf for ged-emacs-devel@m.gmane.org; Tue, 30 Jan 2018 17:59:35 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:42435) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1egequ-0007c0-EV for emacs-devel@gnu.org; Tue, 30 Jan 2018 17:59:27 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1egepS-0008OL-Nt for emacs-devel@gnu.org; Tue, 30 Jan 2018 17:58:08 -0500 Original-Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:46437) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1egepS-0008Mv-3v for emacs-devel@gnu.org; Tue, 30 Jan 2018 17:56:38 -0500 Original-Received: by mail-qk0-x242.google.com with SMTP id l64so12375064qke.13 for ; Tue, 30 Jan 2018 14:56:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=orbitalimpact.com; s=google; h=from:to:cc:subject:in-reply-to:date:message-id:mime-version; bh=PTw5n5++BBpwKjdN+g/KdnbAiuRSJumrtj0yUUBgdS8=; b=OkwUsvyVHJsctv1kUBhipKbD2iXBA26DlKBT54qGW66LAkX6wvneeMSpdyN033J53H xOtORrnUsYSjwK56RdKfQxwjkm9ANHrpTipWelTENN1tQKvHWduP3DOP54ot0Zu0o4uv dUYGutQagZzkbRcAWdUOp1Q2Fmlro4qV/vk54= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:date:message-id :mime-version; bh=PTw5n5++BBpwKjdN+g/KdnbAiuRSJumrtj0yUUBgdS8=; b=dseLwId2JTlrno6sWkv0fygUjvePyEwv1HbmkJgNUm5v0Kfk+3tXYxKFOGgQBl5kLN xEJodX4XCddB3um+FMmLuhXB70kOdWi2qlkyBrwP3kueHyf4/JAZmkIHvIiDXIi0yr4T ykE2OHNPKcQbqq0ZtV18hCNoeG9f4/yVOlP+slRgQQ9DAiVk97MkNyLpjb4lWCEXbnfw UP+QjbWzfl3wGGa1cNbYo8tv7+MbdvIh5/xOmlLMAq9/B4bpLNtdvmnw4ZRKCUuiUDCg NT6gvY11JtE6ybsGBQkkBLrXR1SilDbtpLiymEQ8x+76aPuvHiIq+hwyDRLtvERTH/dJ rwNA== X-Gm-Message-State: AKwxytfBJ0eCd9ePWq8TZGgHp+4W5aJenf2CeJqeMVoXTUK5bP6aH7S/ zGaWLWn3+qtDbxxQibxC5se6wKnxRJROL4B8 X-Google-Smtp-Source: AH8x224NOjstm62M4PlywNkDaROGzsuEzMxojPIG6DNqgMsf58W7EozJjucD62uVSWooSJHF8KAI+A== X-Received: by 10.55.21.80 with SMTP id f77mr278419qkh.85.1517352997230; Tue, 30 Jan 2018 14:56:37 -0800 (PST) Original-Received: from lehi.dev.orbitalimpact.com (ip-9-221-239-173.east.us.northamericancoax.com. [173.239.221.9]) by smtp.gmail.com with ESMTPSA id i39sm12366825qte.19.2018.01.30.14.56.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Jan 2018 14:56:36 -0800 (PST) In-Reply-To: (message from George Plymale II on Tue, 30 Jan 2018 17:33:25 -0500) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::242 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:222323 Archived-At: --=-=-= Content-Type: text/plain One more thing in addition to my last message, I noticed that Stefan's patch does not work on Emacs 25.3, as the second hunk fails. It looks like the code is different there so I can only assume that Stefan is on a newer version of Emacs. I have attached the patch that should work on Emacs 25.3 in case anyone wants to try it on 25.3. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=stefans_patch_adapted_for_emacs_25.3.patch Content-Transfer-Encoding: quoted-printable Content-Description: Stefan's patch adapted for Emacs 25.3 diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 32200227de..1fa6ce4758 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -656,6 +656,8 @@ PKG-DESC is a `package-desc' object." (defvar Info-directory-list) (declare-function info-initialize "info" ()) =20 +(defvar package--fastpath-pkgs t) + (defun package--load-files-for-activation (pkg-desc reload) "Load files for activating a package given by PKG-DESC. Load the autoloads file, and ensure `load-path' is setup. If @@ -696,16 +698,19 @@ correspond to previously loaded files (those returned= by (unless (package-activate (car req)) (error "Unable to activate package `%s'.\nRequired package `%s-%= s' is unavailable" name (car req) (package-version-join (cadr req)))))) - (package--load-files-for-activation pkg-desc reload) - ;; Add info node. - (when (file-exists-p (expand-file-name "dir" pkg-dir)) - ;; FIXME: not the friendliest, but simple. - (require 'info) - (info-initialize) - (push pkg-dir Info-directory-list)) - (push name package-activated-list) - ;; Don't return nil. - t)) + (if (listp package--fastpath-pkgs) + ;; We're only collecting the set of packages to activate! + (push pkg-desc package--fastpath-pkgs) + (package--load-files-for-activation pkg-desc reload) + ;; Add info node. + (when (file-exists-p (expand-file-name "dir" pkg-dir)) + ;; FIXME: not the friendliest, but simple. + (require 'info) + (info-initialize) + (push pkg-dir Info-directory-list)) + (push name package-activated-list) + ;; Don't return nil. + t))) =20 (declare-function find-library-name "find-func" (library)) =20 @@ -3437,6 +3442,51 @@ The list is displayed in a buffer named `*Packages*'= ." (interactive) (list-packages t)) =20 +;;;; Fast-path for activation! + +(defcustom package-fastpath-file (locate-user-emacs-file "package-fastpath= .el") + "Location of the file used to speed up activation of packages at startup= ." + :type 'file) + +(defun package-fastpath-refresh () + "(Re)Generate the `package-fastpath-file'." + (interactive) + (package-initialize 'no-activate) + (let ((package--fastpath-pkgs ()) + ;; Pretend we haven't activated anything yet! + (package-activated-list ())) + (dolist (elt package-alist) + (condition-case err + (package-activate (car elt)) + ;; Don't let failure of activation of a package arbitrarily stop + ;; activation of further packages. + (error (message "%s" (error-message-string err))))) + (with-temp-file package-fastpath-file + (insert ";;; FastPath file to speed up package activation at startup= -*- lexical-binding:t -*-\n") + (insert ";; =C2=A1=C2=A1 This file is autogenerated, DO NOT EDIT !!\= n\n") + (dolist (pkg package--fastpath-pkgs) + (let* ((file (locate-library (package--autoloads-file-name pkg))) + (pfile (prin1-to-string file))) + (insert "(let ((load-file-name " pfile "))\n") + (insert-file-contents file) + (while (search-forward "#$" nil 'move) + (replace-match pfile t t)) + (unless (bolp) (insert "\n")) + (insert ")\n"))) + (pp `(setq package-activated-list + (append ',(mapcar #'package-desc-name package--fastpath-p= kgs) + package-activated-list)) + (current-buffer)) + (insert " +;; Local Variables: +;; version-control: never +;; no-byte-compile: nil +;; no-update-autoloads: t +;; End: +")))) + + + (provide 'package) =20 ;;; package.el ends here --=-=-=--