# HG changeset patch # User Gerd Moellmann # Date 942758991 0 # Node ID b325726661743dde613f5612026b8b4fe1c3f486 # Parent b9ad44d699ec411963017554181ea4b6fc1fb7b6 (with-syntax-table): New. diff -r b9ad44d699ec -r b32572666174 lisp/simple.el --- a/lisp/simple.el Tue Nov 16 13:27:36 1999 +0000 +++ b/lisp/simple.el Tue Nov 16 13:29:51 1999 +0000 @@ -27,6 +27,10 @@ ;;; Code: +(eval-when-compile + (require 'cl)) + + (defgroup killing nil "Killing and yanking commands" :group 'editing) @@ -4132,4 +4136,21 @@ (if display-flag (pop-to-buffer new)) new)) + +(defmacro with-syntax-table (table &rest body) + "Evaluate BODY with syntax table of current buffer set to a copy of TABLE. +Point, mark, current buffer, and syntax table are saved, BODY is +evaluated, and the saved values are restored, even in case of an +abnormal exit. Value is what BODY returns." + (let ((old-table (gensym))) + '(let ((,old-table (syntax-table))) + (unwind-protect + (save-excursion + (set-syntax-table (copy-syntax-table ,table)) + ,@body) + (set-syntax-table ,old-table))))) + +(put 'with-syntax-table 'lisp-indent-function 1) +(put 'with-syntax-table 'edebug-form-spec '(form body)) + ;;; simple.el ends here