diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2000-03-21 15:28:44 +0000 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2000-03-21 15:28:44 +0000 |
commit | c834b52cdce6b71d976bc1d1e1936c0896b6fbb5 (patch) | |
tree | c1945ba2f13bbd8995a80c1c52c677710222dff2 /lisp/subr.el | |
parent | 6c4bfdc0b738f865199859fbd4f7be88f21429cb (diff) | |
download | emacs-c834b52cdce6b71d976bc1d1e1936c0896b6fbb5.tar.gz |
(combine-run-hooks): New function.
Diffstat (limited to 'lisp/subr.el')
-rw-r--r-- | lisp/subr.el | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 9074d3bbd3e..ee6eadaa59f 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1089,6 +1089,35 @@ in BODY." . ,body) (combine-after-change-execute))) + +(defvar combine-run-hooks t + "List of hooks delayed. Or t if we're not delaying hooks.") + +(defmacro combine-run-hooks (&rest body) + "Execute BODY, but delay any `run-hooks' until the end." + (let ((saved-combine-run-hooks (make-symbol "saved-combine-run-hooks")) + (saved-run-hooks (make-symbol "saved-run-hooks"))) + `(let ((,saved-combine-run-hooks combine-run-hooks) + (,saved-run-hooks (symbol-function 'run-hooks))) + (unwind-protect + (progn + ;; If we're not delaying hooks yet, setup the delaying mode + (unless (listp combine-run-hooks) + (setq combine-run-hooks nil) + (fset 'run-hooks + ,(lambda (&rest hooks) + (setq combine-run-hooks + (append combine-run-hooks hooks))))) + ,@body) + ;; If we were not already delaying, then it's now time to set things + ;; back to normal and to execute the delayed hooks. + (unless (listp ,saved-combine-run-hooks) + (setq ,saved-combine-run-hooks combine-run-hooks) + (fset 'run-hooks ,saved-run-hooks) + (setq combine-run-hooks t) + (apply 'run-hooks ,saved-combine-run-hooks)))))) + + (defmacro with-syntax-table (table &rest body) "Evaluate BODY with syntax table of current buffer set to a copy of TABLE. The syntax table of the current buffer is saved, BODY is evaluated, and the |