comparison lisp/simple.el @ 26521:5efbe3ff1f09

(with-syntax-table): Don't switch buffers.
author Gerd Moellmann <gerd@gnu.org>
date Sun, 21 Nov 1999 15:07:25 +0000
parents 0044d20f41ae
children b4f7c98850f0
comparison
equal deleted inserted replaced
26520:bd832bb8fbc0 26521:5efbe3ff1f09
4140 new)) 4140 new))
4141 4141
4142 4142
4143 (defmacro with-syntax-table (table &rest body) 4143 (defmacro with-syntax-table (table &rest body)
4144 "Evaluate BODY with syntax table of current buffer set to a copy of TABLE. 4144 "Evaluate BODY with syntax table of current buffer set to a copy of TABLE.
4145 Current buffer and syntax table are saved, BODY is evaluated, and the 4145 The syntax table of the current buffer is saved, BODY is evaluated, and the
4146 saved values are restored, even in case of an abnormal exit. 4146 saved table is restored, even in case of an abnormal exit.
4147 Value is what BODY returns." 4147 Value is what BODY returns."
4148 (let ((old-table (gensym)) 4148 (let ((old-table (gensym))
4149 (old-buffer (gensym))) 4149 (old-buffer (gensym)))
4150 '(let ((,old-table (syntax-table)) 4150 '(let ((,old-table (syntax-table))
4151 (,old-buffer (current-buffer))) 4151 (,old-buffer (current-buffer)))
4152 (unwind-protect 4152 (unwind-protect
4153 (progn 4153 (progn
4154 (set-syntax-table (copy-syntax-table ,table)) 4154 (set-syntax-table (copy-syntax-table ,table))
4155 ,@body) 4155 ,@body)
4156 (set-buffer ,old-buffer) 4156 (save-current-buffer
4157 (set-syntax-table ,old-table))))) 4157 (set-buffer ,old-buffer)
4158 (set-syntax-table ,old-table))))))
4158 4159
4159 (put 'with-syntax-table 'lisp-indent-function 1) 4160 (put 'with-syntax-table 'lisp-indent-function 1)
4160 (put 'with-syntax-table 'edebug-form-spec '(form body)) 4161 (put 'with-syntax-table 'edebug-form-spec '(form body))
4161 4162
4162 ;;; simple.el ends here 4163 ;;; simple.el ends here