From 437a819ea16f280e7b13de9849a2264da49845c0 Mon Sep 17 00:00:00 2001 From: syl20bnr Date: Fri, 14 Aug 2015 15:31:22 -0400 Subject: [PATCH] core: inline recipe in package list It is now possible to override the recipe in a custom layer. For instance to override the recipe R for package P in layer L In a private layer L' put at the end of dotspacemacs-configuration-layers and listing P with an init function for P, L' becomes the ower of P and the recipe R' defined in L' overrides the recipe R. --- contrib/!lang/php/packages.el | 5 +---- core/core-configuration-layer.el | 10 +++++----- core/tests/core-configuration-layer-utest.el | 8 ++++---- spacemacs/packages.el | 5 +---- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/contrib/!lang/php/packages.el b/contrib/!lang/php/packages.el index 91f38840b..dae56490d 100644 --- a/contrib/!lang/php/packages.el +++ b/contrib/!lang/php/packages.el @@ -18,16 +18,13 @@ ggtags helm-gtags php-auto-yasnippets - (php-extras :location recipe) + (php-extras :location (recipe :fetcher github :repo "arnested/php-extras")) php-mode phpcbf phpunit flycheck )) -(setq php-package-recipes - '((php-extras :fetcher github :repo "arnested/php-extras"))) - (defun php/init-drupal-mode () (use-package drupal-mode :defer t)) diff --git a/core/core-configuration-layer.el b/core/core-configuration-layer.el index f41af872b..53cf80291 100644 --- a/core/core-configuration-layer.el +++ b/core/core-configuration-layer.el @@ -97,7 +97,9 @@ :documentation "Layers with a post-init function.") (location :initarg :location :initform elpa - :type (satisfies (lambda (x) (member x '(local elpa recipe)))) + :type (satisfies (lambda (x) + (or (member x '(local elpa)) + (and (listp x) (eq 'recipe (car x)))))) :documentation "Location of the package.") (step :initarg :step :initform nil @@ -567,7 +569,7 @@ LAYERS is a list of layer symbols." (cond ((eq 'elpa location) (configuration-layer//install-from-elpa pkg)) - ((eq 'recipe location) + ((and (listp location) (eq 'recipe (car location))) (configuration-layer//install-from-recipe pkg)) (t (spacemacs-buffer/warning "Unknown location %S for package %S." location pkg-name))) @@ -596,9 +598,7 @@ LAYERS is a list of layer symbols." "Install PKG from a recipe." (let* ((pgk-name (oref pkg :name)) (layer (oref pkg :owner)) - (recipes-var (intern (format "%S-package-recipes" layer))) - (recipe (when (boundp recipes-var) - (assq pkg-name (symbol-value recipes-var))))) + (recipe (cons pkg-name (cdr (oref pkg :location))))) (if recipe (quelpa recipe) (spacemacs-buffer/warning diff --git a/core/tests/core-configuration-layer-utest.el b/core/tests/core-configuration-layer-utest.el index 0604a4aea..883e52358 100644 --- a/core/tests/core-configuration-layer-utest.el +++ b/core/tests/core-configuration-layer-utest.el @@ -185,7 +185,7 @@ (let* ((layer1 (cfgl-layer "layer1" :name 'layer1 :dir "/path")) (layers (list layer1)) (layer1-packages '((pkg1 :location elpa :excluded t) - (pkg2 :location recipe) + (pkg2 :location (recipe blahblah)) (pkg3 :location local :step pre))) (mocker-mock-default-record-cls 'mocker-stub-record)) (defun layer1/init-pkg1 nil) @@ -196,7 +196,7 @@ (:output nil :occur 1))) (configuration-layer/layer-usedp (l) ((:output t :occur 1)))) (should (equal (list (cfgl-package "pkg3" :name 'pkg3 :owner 'layer1 :location 'local :step 'pre) - (cfgl-package "pkg2" :name 'pkg2 :owner 'layer1 :location 'recipe) + (cfgl-package "pkg2" :name 'pkg2 :owner 'layer1 :location '(recipe blahblah)) (cfgl-package "pkg1" :name 'pkg1 :owner 'layer1 :excluded t)) (configuration-layer/get-packages layers)))))) @@ -204,7 +204,7 @@ (let* ((layer1 (cfgl-layer "layer1" :name 'layer1 :dir "/path")) (layers (list layer1)) (layer1-packages '(pkg1 - (pkg2 :location recipe) + (pkg2 :location (recipe blahblah)) (pkg3 :location local :step pre) pkg4)) (mocker-mock-default-record-cls 'mocker-stub-record)) @@ -218,7 +218,7 @@ (configuration-layer/layer-usedp (l) ((:output t :occur 1)))) (should (equal (list (cfgl-package "pkg4" :name 'pkg4 :owner 'layer1) (cfgl-package "pkg3" :name 'pkg3 :owner 'layer1 :location 'local :step 'pre) - (cfgl-package "pkg2" :name 'pkg2 :owner 'layer1 :location 'recipe) + (cfgl-package "pkg2" :name 'pkg2 :owner 'layer1 :location '(recipe blahblah)) (cfgl-package "pkg1" :name 'pkg1 :owner 'layer1)) (configuration-layer/get-packages layers)))))) diff --git a/spacemacs/packages.el b/spacemacs/packages.el index 918701e0a..582ff85ed 100644 --- a/spacemacs/packages.el +++ b/spacemacs/packages.el @@ -42,7 +42,7 @@ evil-escape evil-exchange evil-iedit-state - (evil-indent-textobject :location recipe) + (evil-indent-textobject :location (recipe :fetcher github :repo "TheBB/evil-indent-textobject")) evil-jumper evil-leader evil-lisp-state @@ -125,9 +125,6 @@ (push '(paradox :location local) spacemacs-packages) (push 'paradox spacemacs-packages)) -(setq spacemacs-package-recipes - '((evil-indent-textobject :fetcher github :repo "TheBB/evil-indent-textobject"))) - ;; Initialization of packages (defun spacemacs/init-ace-link ()