Add support for use-package injected hooks
This commit is contained in:
parent
7d7928a21b
commit
ee862ce124
|
@ -20,6 +20,7 @@
|
|||
(require 'core-spacemacs-buffer)
|
||||
(require 'core-toggle)
|
||||
(require 'core-micro-state)
|
||||
(require 'core-use-package-ext)
|
||||
|
||||
(defconst spacemacs-repository "spacemacs"
|
||||
"Name of the Spacemacs remote repository.")
|
||||
|
@ -121,6 +122,9 @@ initialization."
|
|||
;; bind-key is required by use-package
|
||||
(spacemacs/load-or-install-package 'bind-key t)
|
||||
(spacemacs/load-or-install-package 'use-package t)
|
||||
;; inject use-package hooks for easy customization of
|
||||
;; stock package configuration
|
||||
(setq use-package-inject-hooks t)
|
||||
;; evil and evil-leader must be installed at the beginning of the
|
||||
;; boot sequence.
|
||||
;; Use C-u as scroll-up (must be set before actually loading evil)
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
;;; core-use-package-ext.el --- Spacemacs Core File
|
||||
;;
|
||||
;; Copyright (c) 2012-2014 Sylvain Benner
|
||||
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
|
||||
;;
|
||||
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
||||
;; URL: https://github.com/syl20bnr/spacemacs
|
||||
;;
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;;; License: GPLv3
|
||||
(defconst spacemacs--use-package-add-hook-keywords '(:pre-init
|
||||
:post-init
|
||||
:pre-config
|
||||
:post-config))
|
||||
|
||||
(defmacro spacemacs|use-package-add-hook (name &rest plist)
|
||||
"Add post hooks to `:init' or `:config' arguments of an existing
|
||||
configuration.
|
||||
|
||||
In order to use this macro the variable `use-package-inject-hooks'
|
||||
must be non-nil.
|
||||
|
||||
This is useful in the dotfile to override the default configuration
|
||||
of a package.
|
||||
|
||||
Usage:
|
||||
|
||||
(use-package-add-hook package-name
|
||||
[:keyword [option]]...)
|
||||
|
||||
:pre-init Code to run before the default `:init' configuration.
|
||||
:post-init Code to run after the default `:init' configuration.
|
||||
:pre-config Code to run before the default `:config' configuration.
|
||||
:post-config Code to run after the default `:config' configuration.
|
||||
|
||||
In practice the most useful hook is the `:post-config' where you can
|
||||
override lazy-loaded settings."
|
||||
(declare (indent 1))
|
||||
(let ((name-symbol (if (stringp name) (intern name) name))
|
||||
(expanded-forms '()))
|
||||
(dolist (keyword spacemacs--use-package-add-hook-keywords)
|
||||
(let ((body (spacemacs/mplist-get plist keyword)))
|
||||
(when body
|
||||
(let ((hook (intern (format "use-package--%S--%s-hook"
|
||||
name-symbol
|
||||
(substring (format "%s" keyword) 1)))))
|
||||
(push `(add-hook ',hook (lambda nil ,@body)) expanded-forms)))))
|
||||
`(progn ,@expanded-forms)))
|
||||
|
||||
(provide 'core-use-package-ext)
|
Loading…
Reference in New Issue