core: fix potential undefined function error with transient hooks

Fixes #10930
This commit is contained in:
syl20bnr 2018-07-04 15:38:15 -04:00
parent ba2f692366
commit a861177c4a
1 changed files with 5 additions and 2 deletions

View File

@ -53,8 +53,11 @@ If FUNC is a lambda you must give it a name with FNAME. "
,(if (functionp hook)
`(advice-remove ',hook ',hfunc)
`(remove-hook ',hook ',hfunc))
(fmakunbound ',hfunc)
,(when fname `(fmakunbound ',fname)))))
;; instead of unbinding we reset the
;; functions to be the `ignore' function.
;; see: https://github.com/syl20bnr/spacemacs/issues/10930
(fset ',hfunc 'ignore)
,(when fname `(fset ',fname 'ignore)))))
(if (functionp hook)
`((advice-add ',hook :before ',hfunc))
`((add-hook ',hook ',hfunc)))))