I have a list of packages installed that I would want to install on another computer. How would I use the info in the packages buffer or some other list to generate a script that would be used to install them on another computer?

async              20170610.2241 installed
epl                20150517.433  installed
evil               20170712.2350 installed
goto-chg           20131228.659  installed
helm               20170706.648  installed
helm-ag            20170209.745  installed
helm-core          20170701.629  installed
helm-descbinds     20160916.713  installed
helm-projectile    20170613.14   installed
pkg-info           20150517.443  installed
popup              20160709.729  installed
projectile         20170416.148  installed
undo-tree          20170706.246  installed

3 Answers 3


Add the packages you want to package-selected-packages and run package-install-selected-packages.

In your case:

(setq package-selected-packages

C-h v package-selected-packages RET and C-h f package-install-selected-packages RET are your friends.

  • How would I extract the list of installed packages in code, i.e. to generate the script here automatically, so I could paste it into a file?
    – vfclists
    Jul 15, 2017 at 7:22
  • I am not quite sure what you are asking in this comment. could you please ask a separate question? thanks!
    – sds
    Jul 16, 2017 at 2:32
  • I asked the new question here -emacs.stackexchange.com/questions/34205/…
    – vfclists
    Jul 16, 2017 at 8:24
  • When I enter C-h f package-install-selected-packages I get No match. Which emacs version is the function built in? Can package-install iterate over a list of packages?
    – vfclists
    Jul 16, 2017 at 13:51
  • Emacs 26.0.50. What does the help for the variable say?
    – sds
    Jul 16, 2017 at 14:22

You can use use-package to combine making sure a package is installed with the configuration for the package. Set up use-package with this code in your init file:

(unless (package-installed-p 'use-package)
  (package-install 'use-package))

(eval-when-compile (require 'use-package))

(use-package use-package
  (setq use-package-always-ensure t))

And then you can install packages this way, e.g., projectile:

(use-package projectile

Now, when you put that init file on a new system, and start up Emacs, use-package will make sure those packages are installed.


Try to use this code. All packages`ll be installed at launch, just dont forget to include this script before other package

(require 'cl)
;; Guarantee all packages are installed on start
(defvar packages-list
    ;; Example package list
  "List of packages needs to be installed at launch")

(defun has-package-not-installed ()
  (loop for p in packages-list
        when (not (package-installed-p p)) do (return t)
        finally (return nil)))

(when (has-package-not-installed)
  ;; Check for new packages (package versions)
  (message "%s" "Get latest versions of all packages...")
  (message "%s" " done.")
  ;; Install the missing packages
  (dolist (p packages-list)
    (when (not (package-installed-p p))
      (package-install p))))

p.s i didnt write this code, ive just found it somewhere on stackoverflow

Or try to use Cask

  • You can probably use #'cl-some (from 'cl-extra') instead of the loop statement in #'has-package-not-installed`. Just fyi.
    – zck
    Jul 14, 2017 at 18:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.