summary refs log tree commit diff stats
path: root/tag-emacs/emacs.d
diff options
context:
space:
mode:
authorAlan Pearce2016-07-07 16:24:11 +0200
committerAlan Pearce2016-07-07 16:24:31 +0200
commit6afa8022aa833d2452cf16b4161f5258276b4688 (patch)
treebf0f7c49a07befe6587da41f3828c136dd48c901 /tag-emacs/emacs.d
parent94489bb8ce88f65c6a440f4f0953ad00248a1ab9 (diff)
downloaddotfiles-6afa8022aa833d2452cf16b4161f5258276b4688.tar.lz
dotfiles-6afa8022aa833d2452cf16b4161f5258276b4688.tar.zst
dotfiles-6afa8022aa833d2452cf16b4161f5258276b4688.zip
Emacs: Avoid using MELPA for packages
Create a whitelist of desired packages that are not (at the current
time) available elsewhere
Diffstat (limited to 'tag-emacs/emacs.d')
-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/")