[core] Make spacemacs|use-package-add-hook emit code for warning generation
In my first commit I did not add the warning message properly. Basically the macro should emit code to create a warning if the generated code is run and the predicate is not fulfilled. However in my last commit it did run the code during macro expansion which would do the testing there which is not what I wanted.
This commit is contained in:
parent
fbb8354c89
commit
6e6bbe039e
|
@ -18,7 +18,7 @@
|
|||
configuration.
|
||||
|
||||
In order to use this macro the variable `use-package-inject-hooks'
|
||||
must be non-nil.
|
||||
must be non-nil. If it is not a warning will be issued.
|
||||
|
||||
This is useful in the dotfile to override the default configuration
|
||||
of a package.
|
||||
|
@ -36,12 +36,6 @@ Usage:
|
|||
In practice the most useful hook is the `:post-config' where you can
|
||||
override lazy-loaded settings."
|
||||
(declare (indent 1))
|
||||
;; Make sure to yell when someone tries to call this without
|
||||
;; `use-package-inject-hooks'.
|
||||
(when (not use-package-inject-hooks)
|
||||
(message (concat "!!!!!!WARNING!!!!!! Called use-package-add-hook without"
|
||||
" "
|
||||
"use-package-inject-hooks non-nil, this will most probably not work.")))
|
||||
(let ((name-symbol (if (stringp name) (intern name) name))
|
||||
(expanded-forms '()))
|
||||
(dolist (keyword spacemacs--use-package-add-hook-keywords)
|
||||
|
@ -51,6 +45,12 @@ override lazy-loaded settings."
|
|||
name-symbol
|
||||
(substring (format "%s" keyword) 1)))))
|
||||
(push `(add-hook ',hook (lambda nil ,@body t)) expanded-forms)))))
|
||||
(push `(when (not use-package-inject-hooks)
|
||||
(message (concat "!!!!!!WARNING!!!!!! Called use-package-add-hook without"
|
||||
" "
|
||||
"use-package-inject-hooks non-nil, this will most probably not work.")))
|
||||
expanded-forms)
|
||||
|
||||
`(progn ,@expanded-forms)))
|
||||
|
||||
(provide 'core-use-package-ext)
|
||||
|
|
Loading…
Reference in New Issue