Function: package-quickstart-refresh

package-quickstart-refresh is an interactive and byte-compiled function defined in package.el.gz.

Signature

(package-quickstart-refresh)

Documentation

(Re)Generate the package-quickstart-file.

View in manual

Probably introduced at or before Emacs version 27.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/package.el.gz
(defun package-quickstart-refresh ()
  "(Re)Generate the `package-quickstart-file'."
  (interactive)
  (package-initialize 'no-activate)
  (require 'info)
  (let ((package--quickstart-pkgs ())
        ;; Pretend we haven't activated anything yet!
        (package-activated-list ())
        ;; Make sure we can load this file without load-source-file-function.
        (coding-system-for-write 'emacs-internal)
        ;; Ensure that `pp' and `prin1-to-string' calls further down
        ;; aren't truncated.
        (print-length nil)
        (print-level nil)
        (Info-directory-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)))))
    (setq package--quickstart-pkgs (nreverse package--quickstart-pkgs))
    (with-temp-file package-quickstart-file
      (emacs-lisp-mode)                 ;For `syntax-ppss'.
      (insert ";;; Quickstart file to activate all packages at startup  -*- lexical-binding:t -*-\n")
      (insert ";; ¡¡ This file is autogenerated by `package-quickstart-refresh', DO NOT EDIT !!\n\n")
      (dolist (pkg package--quickstart-pkgs)
        (let* ((file
                ;; Prefer uncompiled files (and don't accept .so files).
                (let ((load-suffixes '(".el" ".elc")))
                  (locate-library (package--autoloads-file-name pkg))))
               (pfile (prin1-to-string file)))
          (insert "(let* ((load-file-name " pfile ")\
\(load-true-file-name load-file-name))\n")
          (insert-file-contents file)
          ;; Fixup the special #$ reader form and throw away comments.
          (while (re-search-forward "#\\$\\|^;\\(.*\n\\)" nil 'move)
            (unless (ppss-string-terminator (save-match-data (syntax-ppss)))
              (replace-match (if (match-end 1) "" pfile) t t)))
          (unless (bolp) (insert "\n"))
          (insert ")\n")))
      (pp `(defvar package-activated-list) (current-buffer))
      (pp `(setq package-activated-list
                 (delete-dups
                  (append ',(mapcar #'package-desc-name package--quickstart-pkgs)
                          package-activated-list)))
          (current-buffer))
      (let ((info-dirs (butlast Info-directory-list)))
        (when info-dirs
          (pp `(progn (require 'info)
                      (info-initialize)
                      (setq Info-directory-list
                            (append ',info-dirs Info-directory-list)))
              (current-buffer))))
      ;; Use `\s' instead of a space character, so this code chunk is not
      ;; mistaken for an actual file-local section of package.el.
      (insert "
;; Local\sVariables:
;; version-control: never
;; no-update-autoloads: t
;; byte-compile-warnings: (not make-local)
;; End:
"))
    ;; FIXME: Do it asynchronously in an Emacs subprocess, and
    ;; don't show the byte-compiler warnings.
    (byte-compile-file package-quickstart-file)))