diff --git a/core/core-spacemacs.el b/core/core-spacemacs.el
index 94316979c..1d2c09720 100644
--- a/core/core-spacemacs.el
+++ b/core/core-spacemacs.el
@@ -82,6 +82,8 @@ the final step of executing code in `emacs-startup-hook'.")
;; explicitly set the preferred coding systems to avoid annoying prompt
;; from emacs (especially on Microsoft Windows)
(prefer-coding-system 'utf-8)
+ ;; Extend use package if already installed
+ (spacemacs/use-package-extend)
;; TODO move these variables when evil is removed from the bootstrapped
;; packages.
(setq-default evil-want-C-u-scroll t
diff --git a/core/core-use-package-ext.el b/core/core-use-package-ext.el
index 00e5b227c..0d1aeb9e5 100644
--- a/core/core-use-package-ext.el
+++ b/core/core-use-package-ext.el
@@ -19,12 +19,16 @@
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see .
+(require 'core-fonts-support)
+(require 'core-spacebind)
(defconst spacemacs--use-package-add-hook-keywords '(:pre-init
:post-init
:pre-config
:post-config))
+(defvar spacemacs--use-package-extended nil)
+
(defmacro spacemacs|use-package-add-hook (name &rest plist)
"Add post hooks to `:init' or `:config' arguments of an existing
configuration.
@@ -59,4 +63,101 @@ override lazy-loaded settings."
(push `(add-hook ',hook (lambda nil ,@body t)) expanded-forms)))))
`(progn ,@expanded-forms)))
+
+
+(defun spacemacs/use-package-extend ()
+ "Extend use-package with custom keywords."
+ (when (and (require 'use-package nil t) (not spacemacs--use-package-extended))
+ (setq use-package-verbose init-file-debug
+ ;; inject use-package hooks for easy customization of stock package
+ ;; configuration
+ spacemacs--use-package-extended t
+ use-package-inject-hooks t)
+ (add-to-list 'use-package-keywords :spacebind t)
+ (add-to-list 'use-package-keywords :spacediminish t)))
+
+(defun use-package-normalize/:spacebind (name-symbol keyword args)
+ (use-package-only-one (symbol-name keyword) args
+ (lambda (label arg)
+ (if (and (listp arg) (keywordp (car arg)))
+ arg
+ (use-package-error
+ ":spacebind wants an arg list compatible with `spacebind' macro")))))
+
+(defun use-package-handler/:spacebind (name-symbol keyword args rest state)
+ (let ((body (use-package-process-keywords name-symbol rest state)))
+ (if (null args)
+ body
+ (use-package-concat
+ body
+ `((spacemacs|spacebind ,@args))))))
+
+(defun use-package-normalize/:spacediminish (name keyword args)
+ (use-package-as-one (symbol-name keyword) args
+ (apply-partially #'use-package-normalize-spacediminish name) t))
+
+(defun use-package-handler/:spacediminish (name _keyword arg rest state)
+ (let ((body (use-package-process-keywords name rest state)))
+ (use-package-concat
+ `((when (fboundp 'spacemacs|diminish)
+ ,@(if (consp (car arg)) ;; e.g. ((MODE FOO BAR) ...)
+ (mapcar (lambda (var) `(spacemacs|diminish ,@var))
+ arg)
+ `((spacemacs|diminish ,@arg))))) ;; e.g. (MODE FOO BAR)
+ body)))
+
+(defun use-package-normalize-spacediminish (name label arg &optional recursed)
+ "Normalize the arguments to `spacemacs|diminish' to a list of one of six forms:
+ t
+ SYMBOL
+ STRING
+ (SYMBOL STRING)
+ (STRING STRING)
+ (SYMBOL STRING STRING)"
+ (let ((default-mode (use-package-as-mode name)))
+ (pcase arg
+ ;; (PATTERN ..) when not recursive -> go to recursive case
+ ((and (or `(,x . ,y) `(,x ,y))
+ (guard (and (not recursed)
+ (listp x)
+ (listp y))))
+ (mapcar (lambda (var) (use-package-normalize-spacediminish name label var t))
+ arg))
+ ;; t -> (-mode)
+ ('t
+ (list default-mode))
+ ;; SYMBOL -> (SYMBOL)
+ ((pred use-package-non-nil-symbolp)
+ (list arg))
+ ;; STRING -> (-mode STRING)
+ ((pred stringp)
+ (list default-mode arg))
+ ;; (SYMBOL) when recursed -> (SYMBOL)
+ ((and `(,x)
+ (guard (and recursed (use-package-non-nil-symbolp x))))
+ arg)
+ ;; (STRING) when recursed -> (-mode STRING))
+ ((and `(,x)
+ (guard (and recursed (stringp x))))
+ (cons default-mode arg))
+ ;; (SYMBOL STRING) -> (SYMBOL STRING)
+ ((and `(,x ,y)
+ (guard (and (use-package-non-nil-symbolp x) (stringp y))))
+ arg)
+ ;; (STRING STRING) -> (-mode STRING STRING)
+ ((and `(,x ,y)
+ (guard (and (stringp x) (stringp y))))
+ (cons default-mode arg))
+ ;; (SYMBOL STRING STRING) -> (SYMBOL STRING STRING)
+ ((and `(,x ,y ,z)
+ (guard (and (use-package-non-nil-symbolp x)
+ (stringp y)
+ (stringp z))))
+ arg)
+ (_
+ (use-package-error
+ (format
+ "%s wants a symbol, string, (symbol string), (string string), (symbol string string) or list of these: %S"
+ label arg))))))
+
(provide 'core-use-package-ext)
diff --git a/init.el b/init.el
index 470359219..7c4de98b7 100644
--- a/init.el
+++ b/init.el
@@ -26,7 +26,6 @@
;; Avoid garbage collection during startup.
;; see `SPC h . dotspacemacs-gc-cons' for more info
-(fmakunbound 'use-package)
(defconst emacs-start-time (current-time))
(setq gc-cons-threshold 402653184 gc-cons-percentage 0.6)
(load (concat (file-name-directory load-file-name) "core/core-load-paths")
diff --git a/layers/+distributions/spacemacs-bootstrap/funcs.el b/layers/+distributions/spacemacs-bootstrap/funcs.el
index 32db3a893..4822a2117 100644
--- a/layers/+distributions/spacemacs-bootstrap/funcs.el
+++ b/layers/+distributions/spacemacs-bootstrap/funcs.el
@@ -21,7 +21,6 @@
;; along with this program. If not, see .
-
(defun spacemacs/state-color-face (state)
@@ -227,96 +226,6 @@ the scroll transient state.")
-(defun use-package-normalize/:spacebind (name-symbol keyword args)
- (use-package-only-one (symbol-name keyword) args
- (lambda (label arg)
- (if (and (listp arg) (keywordp (car arg)))
- arg
- (use-package-error
- ":spacebind wants an arg list compatible with `spacebind' macro")))))
-
-(defun use-package-handler/:spacebind (name-symbol keyword args rest state)
- (let ((body (use-package-process-keywords name-symbol rest state)))
- (if (null args)
- body
- (use-package-concat
- body
- `((spacemacs|spacebind ,@args))))))
-
-
-
-(defun use-package-normalize-spacediminish (name label arg &optional recursed)
- "Normalize the arguments to `spacemacs|diminish' to a list of one of six forms:
- t
- SYMBOL
- STRING
- (SYMBOL STRING)
- (STRING STRING)
- (SYMBOL STRING STRING)"
- (let ((default-mode (use-package-as-mode name)))
- (pcase arg
- ;; (PATTERN ..) when not recursive -> go to recursive case
- ((and (or `(,x . ,y) `(,x ,y))
- (guard (and (not recursed)
- (listp x)
- (listp y))))
- (mapcar (lambda (var) (use-package-normalize-spacediminish name label var t))
- arg))
- ;; t -> (-mode)
- ('t
- (list default-mode))
- ;; SYMBOL -> (SYMBOL)
- ((pred use-package-non-nil-symbolp)
- (list arg))
- ;; STRING -> (-mode STRING)
- ((pred stringp)
- (list default-mode arg))
- ;; (SYMBOL) when recursed -> (SYMBOL)
- ((and `(,x)
- (guard (and recursed (use-package-non-nil-symbolp x))))
- arg)
- ;; (STRING) when recursed -> (-mode STRING))
- ((and `(,x)
- (guard (and recursed (stringp x))))
- (cons default-mode arg))
- ;; (SYMBOL STRING) -> (SYMBOL STRING)
- ((and `(,x ,y)
- (guard (and (use-package-non-nil-symbolp x) (stringp y))))
- arg)
- ;; (STRING STRING) -> (-mode STRING STRING)
- ((and `(,x ,y)
- (guard (and (stringp x) (stringp y))))
- (cons default-mode arg))
- ;; (SYMBOL STRING STRING) -> (SYMBOL STRING STRING)
- ((and `(,x ,y ,z)
- (guard (and (use-package-non-nil-symbolp x)
- (stringp y)
- (stringp z))))
- arg)
- (_
- (use-package-error
- (format
- "%s wants a symbol, string, (symbol string), (string string), (symbol string string) or list of these: %S"
- label arg))))))
-
-;;;###autoload
-(defun use-package-normalize/:spacediminish (name keyword args)
- (use-package-as-one (symbol-name keyword) args
- (apply-partially #'use-package-normalize-spacediminish name) t))
-
-;;;###autoload
-(defun use-package-handler/:spacediminish (name _keyword arg rest state)
- (let ((body (use-package-process-keywords name rest state)))
- (use-package-concat
- `((when (fboundp 'spacemacs|diminish)
- ,@(if (consp (car arg)) ;; e.g. ((MODE FOO BAR) ...)
- (mapcar (lambda (var) `(spacemacs|diminish ,@var))
- arg)
- `((spacemacs|diminish ,@arg))))) ;; e.g. (MODE FOO BAR)
- body)))
-
-
-
;; As suggested in the Emacs wiki https://www.emacswiki.org/emacs/HideShow#toc5
(defun spacemacs/toggle-selective-display (column)
"Toggle selective display by column, a.k.a. folding by indentation.
diff --git a/layers/+distributions/spacemacs-bootstrap/packages.el b/layers/+distributions/spacemacs-bootstrap/packages.el
index 344f66c0b..728dc2356 100644
--- a/layers/+distributions/spacemacs-bootstrap/packages.el
+++ b/layers/+distributions/spacemacs-bootstrap/packages.el
@@ -335,13 +335,7 @@
hydra-head-format "[%s] "))
(defun spacemacs-bootstrap/init-use-package ()
- (require 'use-package)
- (setq use-package-verbose init-file-debug
- ;; inject use-package hooks for easy customization of stock package
- ;; configuration
- use-package-inject-hooks t)
- (add-to-list 'use-package-keywords :spacebind t)
- (add-to-list 'use-package-keywords :spacediminish t))
+ (spacemacs/use-package-extend))
(defun spacemacs-bootstrap/init-which-key ()
(require 'which-key)