(delayed-after-hook-functions): Tighten the code a bit

* lisp/subr.el (delayed-mode-hooks, delayed-after-hook-functions):
Use defvar-local.
(run-mode-hooks): Reset delayed-after-hook-functions before running
those functions, in case an error is signaled.

* lisp/emacs-lisp/derived.el (define-derived-mode): Don't duplicate code.
This commit is contained in:
Stefan Monnier 2017-12-27 17:49:39 -05:00
parent f16ba58809
commit fb619c1c22
2 changed files with 9 additions and 13 deletions

View file

@ -281,12 +281,10 @@ No problems result if this variable is not bound.
; Splice in the body (if any).
,@body
)
;; Run the hooks, if any.
(run-mode-hooks ',hook)
,@(when after-hook
`((if delay-mode-hooks
(push (lambda () ,after-hook) delayed-after-hook-functions)
,after-hook)))))))
,@(when after-hook
`((push (lambda () ,after-hook) delayed-after-hook-functions)))
;; Run the hooks (and delayed-after-hook-functions), if any.
(run-mode-hooks ',hook)))))
;; PUBLIC: find the ultimate class of a derived mode.