title: Emacs package install script in init file
body: <p>I restructured my Emacs init files to put them under version control. The file system layout looks like that:</p>
  
  <pre><code>/home/axel/.user_config/emacs
  ├── development.el
  ├── general.el
  ├── init.el
  ├── packages.el
  └── writing.el
  </code></pre>
  
  <p><code>packages.el</code> contains a list of packages Emacs should install on startup if they are not already installed. This works without problems after I do a <code>rm -rf ~/.emacs.d/*</code>. When I start Emacs afterwards, all the packages listed in <code>packages.el</code> are installed. However, when I manually add a package to (e.g. <code>markdown-mode+</code>) to the list <code>pfl-packages</code> in <code>packages.el</code> the new package is not installed when I restart Emacs. Deleting the contents of <code>~/.emacs.d/</code> again solves that problem, but I would like to be able to add package names to the list, which Emacs then automatically installs on startup. Am I missing something crucial about the Emacs initialization process?</p>
  
  <p>Please see the content of the relevant files below.</p>
  
  <p>The file <code>~/.emacs</code>contains the following:</p>
  
  <pre><code>(add-to-list 'load-path "~/.user_config/emacs/")
  (load-library "init")
  </code></pre>
  
  <p>The file <code>~/.user_config/emacs/init.el</code> contains:</p>
  
  <pre><code>;;;; loads the different libraries to set up Emacs accordingly
  
  ;; load the library that sets up package repositories and syncing
  (load-library "packages")
  
  ;; load the library that sets up the general behavior of Emacs
  (load-library "general")
  (load-library "writing")
  (load-library "development")
  </code></pre>
  
  <p>The file <code>packages.el</code> contains the following:</p>
  
  <pre><code>;;;; this library sets up package repositories and allows for syncing    packages
  ;;;; between different machines
  ;;;; to add packages to the syncing, add their repository names to the   list `pfl-packages'
  
  ;;; set up package repositories from which additional packages can be installed
  
  ;; set up ELPA and MELPA repositories
  (package-initialize)
  (add-to-list 'package-archives
                       '("melpa" . "http://melpa.org/packages/"))
  (add-to-list 'package-archives
                       '("org" . "http://orgmode.org/elpa/"))
  
  
  ;;; set up package syncing to allow for syncing between different machines
  
  ;; list of packages to sync
  (setq pfl-packages
          '(
              color-theme-sanityinc-solarized
              company
              company-auctex
              company-c-headers
              company-irony
              company-quickhelp
              elpy
              ess
              flycheck-irony
              irony
              magit
              markdown-mode
              markdown-mode+
              rainbow-delimiters
              smart-tabs-mode
              yasnippet
              ))
  
  ;; refresh package list if it is not already available
  (when (not package-archive-contents) (package-refresh-contents))
  
  ;; install packages from the list that are not yet installed
  (dolist (pkg pfl-packages)
      (when (and (not (package-installed-p pkg)) (assoc pkg package-archive-contents))
          (package-install pkg)))
  </code></pre>