summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--tag-emacs/emacs.d/init.org45
1 files changed, 45 insertions, 0 deletions
diff --git a/tag-emacs/emacs.d/init.org b/tag-emacs/emacs.d/init.org
index 45d2ae7..4c0e259 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/")