From fe0cb43fb80db52a79ef898f8de49560cc5cdd90 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 29 May 2019 15:56:14 -0400 Subject: * lisp/subr.el (add-hook): Turn `append` into `depth` (bug#35508) Make it possible to control the relative ordering of functions on hooks by specifying `depth` in the same was as was possible with `add-function`. * lisp/electric.el (electric--sort-post-self-insertion-hook): Delete function. (electric-indent-mode, electric-layout-mode, electric-quote-mode): * lisp/elec-pair.el (electric-pair-mode): Use new `depth` arg instead of electric--sort-post-self-insertion-hook. * lisp/emacs-lisp/syntax.el (syntax-propertize, syntax-ppss): Use new `depth` arg to make sure noone accidentally gets added after syntax-ppss-flush-cache. * doc/lispref/modes.texi (Setting Hooks): Document new `depth` arg. * test/lisp/subr-tests.el (subr-tests-add-hook-depth): New test. --- lisp/emacs-lisp/syntax.el | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lisp/emacs-lisp/syntax.el') diff --git a/lisp/emacs-lisp/syntax.el b/lisp/emacs-lisp/syntax.el index f1904e64efb..9c6d5b5829f 100644 --- a/lisp/emacs-lisp/syntax.el +++ b/lisp/emacs-lisp/syntax.el @@ -298,7 +298,7 @@ END) suitable for `syntax-propertize-function'." ;; between syntax-ppss and syntax-propertize, we also have to make ;; sure the flush function is installed here (bug#29767). (add-hook 'before-change-functions - #'syntax-ppss-flush-cache t t)) + #'syntax-ppss-flush-cache 99 t)) (save-excursion (with-silent-modifications (make-local-variable 'syntax-propertize--done) ;Just in case! @@ -430,7 +430,7 @@ These are valid when the buffer has no restriction.") ;; Unregister if there's no cache left. Sadly this doesn't work ;; because `before-change-functions' is temporarily bound to nil here. ;; (unless cache - ;; (remove-hook 'before-change-functions 'syntax-ppss-flush-cache t)) + ;; (remove-hook 'before-change-functions #'syntax-ppss-flush-cache t)) (setcar cell last) (setcdr cell cache))) )) @@ -534,13 +534,14 @@ running the hook." ;; Setup the before-change function if necessary. (unless (or ppss-cache ppss-last) - ;; We should be either the very last function on - ;; before-change-functions or the very first on - ;; after-change-functions. ;; Note: combine-change-calls-1 needs to be kept in sync ;; with this! (add-hook 'before-change-functions - 'syntax-ppss-flush-cache t t)) + #'syntax-ppss-flush-cache + ;; We should be either the very last function on + ;; before-change-functions or the very first on + ;; after-change-functions. + 99 t)) ;; Use the best of OLD-POS and CACHE. (if (or (not old-pos) (< old-pos pt-min)) -- cgit v1.2.3