diff options
author | Richard M. Stallman <[email protected]> | 2000-01-12 03:04:55 +0000 |
---|---|---|
committer | Richard M. Stallman <[email protected]> | 2000-01-12 03:04:55 +0000 |
commit | 7e8539cc6857c26a02d6577ed5057d2a610e2fe1 (patch) | |
tree | 7000b7fe777f44722ec6400fd61cf6681b51427b /lisp/subr.el | |
parent | 210bd5c986529d64641a0724ec582749a7f6505a (diff) |
(with-syntax-table): Moved from simple.el.
Diffstat (limited to 'lisp/subr.el')
-rw-r--r-- | lisp/subr.el | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index f90d0d9da0..683bc24794 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1060,6 +1060,22 @@ in BODY." . ,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) |