From 6afa8022aa833d2452cf16b4161f5258276b4688 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 7 Jul 2016 16:24:11 +0200 Subject: Emacs: Avoid using MELPA for packages Create a whitelist of desired packages that are not (at the current time) available elsewhere --- tag-emacs/emacs.d/init.org | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'tag-emacs') diff --git a/tag-emacs/emacs.d/init.org b/tag-emacs/emacs.d/init.org index 45d2ae72..4c0e2593 100644 --- a/tag-emacs/emacs.d/init.org +++ b/tag-emacs/emacs.d/init.org @@ -36,6 +36,51 @@ the buffer to be empty. ** Use-package #+BEGIN_SRC emacs-lisp + (defvar melpa-include-packages '(minimal-theme + highlight-stages + relative-buffers + dired+ + dired-subtree + dired-hacks-utils + dired-narrow + org-caldav + go-projectile + go-rename + go-guru + redshank + restclient + visual-regexp) + "Don't install any MELPA packages except these packages") + + (defvar package-filter-function nil + "Optional predicate function used to internally filter packages used by package.el. + + The function is called with the arguments PACKAGE VERSION ARCHIVE, where + PACKAGE is a symbol, VERSION is a vector as produced by `version-to-list', and + ARCHIVE is the string name of the package archive.") + + ;; Don't take MELPA versions of certain packages + (setq package-filter-function + (lambda (package version archive) + (or (not (string-equal archive "melpa")) + ;; install package in whitelist + (memq package melpa-include-packages) + ;; use all color themes + (string-match (format "%s" package) "-theme")))) + + (defadvice package--add-to-archive-contents + (around filter-packages (package archive) activate) + "Add filtering of available packages using `package-filter-function', if non-nil." + (when (or (null package-filter-function) + (funcall package-filter-function + (car package) + (funcall (if (fboundp 'package-desc-version) + 'package--ac-desc-version + 'package-desc-vers) + (cdr package)) + archive)) + ad-do-it)) + (eval-and-compile (setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/") ("marmalade" . "http://marmalade-repo.org/packages/") -- cgit 1.4.1