comparison lisp/subr.el @ 28234:763c6639628b

(combine-run-hooks): New function.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 21 Mar 2000 15:28:44 +0000
parents 0f14966fe791
children 9958b6d95bd6
comparison
equal deleted inserted replaced
28233:dbbbc64baaa9 28234:763c6639628b
1087 `(unwind-protect 1087 `(unwind-protect
1088 (let ((combine-after-change-calls t)) 1088 (let ((combine-after-change-calls t))
1089 . ,body) 1089 . ,body)
1090 (combine-after-change-execute))) 1090 (combine-after-change-execute)))
1091 1091
1092
1093 (defvar combine-run-hooks t
1094 "List of hooks delayed. Or t if we're not delaying hooks.")
1095
1096 (defmacro combine-run-hooks (&rest body)
1097 "Execute BODY, but delay any `run-hooks' until the end."
1098 (let ((saved-combine-run-hooks (make-symbol "saved-combine-run-hooks"))
1099 (saved-run-hooks (make-symbol "saved-run-hooks")))
1100 `(let ((,saved-combine-run-hooks combine-run-hooks)
1101 (,saved-run-hooks (symbol-function 'run-hooks)))
1102 (unwind-protect
1103 (progn
1104 ;; If we're not delaying hooks yet, setup the delaying mode
1105 (unless (listp combine-run-hooks)
1106 (setq combine-run-hooks nil)
1107 (fset 'run-hooks
1108 ,(lambda (&rest hooks)
1109 (setq combine-run-hooks
1110 (append combine-run-hooks hooks)))))
1111 ,@body)
1112 ;; If we were not already delaying, then it's now time to set things
1113 ;; back to normal and to execute the delayed hooks.
1114 (unless (listp ,saved-combine-run-hooks)
1115 (setq ,saved-combine-run-hooks combine-run-hooks)
1116 (fset 'run-hooks ,saved-run-hooks)
1117 (setq combine-run-hooks t)
1118 (apply 'run-hooks ,saved-combine-run-hooks))))))
1119
1120
1092 (defmacro with-syntax-table (table &rest body) 1121 (defmacro with-syntax-table (table &rest body)
1093 "Evaluate BODY with syntax table of current buffer set to a copy of TABLE. 1122 "Evaluate BODY with syntax table of current buffer set to a copy of TABLE.
1094 The syntax table of the current buffer is saved, BODY is evaluated, and the 1123 The syntax table of the current buffer is saved, BODY is evaluated, and the
1095 saved table is restored, even in case of an abnormal exit. 1124 saved table is restored, even in case of an abnormal exit.
1096 Value is what BODY returns." 1125 Value is what BODY returns."