# HG changeset patch # User Richard M. Stallman # Date 947646295 0 # Node ID f5713c3976369b3f3a87896efc31ef969a704261 # Parent 6a6b75706812a36e359c0757b62ec55f11c3581c (with-syntax-table): Moved from simple.el. diff -r 6a6b75706812 -r f5713c397636 lisp/subr.el --- a/lisp/subr.el Wed Jan 12 03:04:09 2000 +0000 +++ b/lisp/subr.el Wed Jan 12 03:04:55 2000 +0000 @@ -1060,6 +1060,22 @@ . ,body) (combine-after-change-execute))) +(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 +saved table is restored, even in case of an abnormal exit. +Value is what BODY returns." + (let ((old-table (gensym)) + (old-buffer (gensym))) + `(let ((,old-table (syntax-table)) + (,old-buffer (current-buffer))) + (unwind-protect + (progn + (set-syntax-table (copy-syntax-table ,table)) + ,@body) + (save-current-buffer + (set-buffer ,old-buffer) + (set-syntax-table ,old-table)))))) (defvar save-match-data-internal)