Skip to content

How to Choose Packages Between Two ELPA Repositories

ELPA makes Emacs v24 even more delightful to use. You may have run into a situation though where you wanted to install different packages from both Marmalade and MELPA. A common problem here is that because the newest version number always gets chosen for installation, MELPA packages always get chosen over Marmalade, and you may not want that. MELPA thankfully has a solution for that in the form of their own package.

The directions to set up MELPA are straightforward, but, one of my super-powers is not make any sense of directions, so I had a heck of a time getting it working. Aaron’s config gave me a clue, but I still didn’t have it working (I liked his namespace prefixing though so). Once I did get it working though it was really clear what I had done wrong, basically the package load and require order was incorrect, so, here is the right way to do it:

  • Install the melpa package manually as directed; this gives you package you need to use the filtering functionality.
  • Require ‘package to get the ELPA functionality and variables.
  • Add the repo(s) to ‘package-archives so that you can pull from them.
  • Call package-initialize to find the recently installed melpa package.
  • Require ‘melpa to import it and be able to use it.
  • Customize the enable and exclude melpa variables to specify what packages to include or exclude from which repositories.
  • Call package-refresh-contents to update Emacs’s database of which packages it should use as available for installation.
  • Your filtered package list is now available for use, call list-packages to verify.

Here is an example of my situation, I wanted to default to installing the newest package from either GNU or Marmalade for all but two cases where I only wanted the version that was available on MELPA: fill-column-indicator and melpa. Here is the configuration and correct order of calls to make:

(defvar gcr/packages
  "Packages required at runtime.")
(require 'package)
(add-to-list 'package-archives
             '("marmalade" . "") t)
(add-to-list 'package-archives
             '("melpa" . "") t)
(require 'melpa)
(setq package-archive-enable-alist '(("gnu")
(setq package-archive-exclude-alist '(("gnu"
(dolist (package gcr/packages) 
  (when (not (package-installed-p package))
    (condition-case err
        (package-install package)
       (message "%s" (error-message-string err))))))


  1. Johan wrote:

    Keep it dry:

    Friday, August 16, 2013 at 11:30 | Permalink
  2. Boyd Adamson wrote:

    I don’t think you even need the package-archive-exclude-alist entries, since the MELPA packages will always be newer than the ones from the other sources.

    Wednesday, August 28, 2013 at 07:55 | Permalink
  3. Grant wrote:


    If the Melpa version numbers are always date strings then you are right :). In regards to packages being in both places, I had originally wanted package-1 from Melpa and package-2 from Marmalade, so I did use the exclude, but not anymore. I kind of like the correctness of using it, but yea it probably doesn’t matter.

    Wednesday, August 28, 2013 at 09:54 | Permalink

One Trackback/Pingback

  1. […] customize which packages are provided or excluded from which repositories. You can see more details here or from the documentation for the melpa […]

Post a Comment

Your email is never published nor shared. Required fields are marked *