[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Define list of packages in ~/.emacs.d/init.el
From: |
Dan Čermák |
Subject: |
Re: Define list of packages in ~/.emacs.d/init.el |
Date: |
Tue, 28 Nov 2017 18:13:38 +0100 |
Hi Stephan,
I am doing exactly what you are describing using this snippet:
;;
;; Auto-install not yet installed packages
;;
(require 'cl)
(defvar required-packages
'(auctex
yasnippet)
"a list of packages to ensure are installed at launch.")
; method to check if all packages are installed
(defun packages-installed-p ()
(loop for p in required-packages
when (not (package-installed-p p)) do (return nil)
finally (return t)))
; if not all packages are installed, check one by one and install the missing
ones.
(unless (packages-installed-p)
; check for new packages (package versions)
(message "%s" "Emacs is now refreshing its package database...")
(package-refresh-contents)
(message "%s" " done.")
; install the missing packages
(dolist (p required-packages)
(when (not (package-installed-p p))
(package-install p))))
I have basically copy-pasted this from elisp snippets that I found
around the web, so please don't ask me hard questions ;-)
If you want to auto-install packages, add them to the required-packages
list and voila, you are done.
I have used it in this form in Emacs 24. As Emacs 25 automatically
stores a list of installed packages in the variable
package-selected-packages, you can also use that list instead of the
custom required-packages once you upgrade to Emacs > 24.
Cheers,
Dan
Stephan Brauer <stephan@ls42.de> writes:
> Hi,
>
> disclaimer: I'm (obviously) new to emacs.
>
> I've been searching for a way to define a list of packages that I wan't
> to have installed and then have them installed or updated whenever emacs
> is started. I think this way I can easily put my init.el into version
> control and on every system I use for emacs just deploy that file and
> emacs does the rest.
>
> Does someone here know about a way to do that?
>
> I'm using `GNU Emacs 24.5.1`.
>
> Thanks!
>
> Stephan